Posts

Showing posts from September, 2018

how to youtube url change to embed code in php

<?php     $url='https://www.youtube.com/watch?v=aEtTg4dzRTc';   function getYoutubeEmbedUrl($url){     $urlParts   = explode('/', $url);     $vidid      = explode( '&', str_replace('watch?v=', '', end($urlParts) ) );     return 'https://www.youtube.com/embed/' . $vidid[0]; } $embed_url= getYoutubeEmbedUrl($url); echo $embed_url; ?>

ajax complete method for show loader in jquery

$(document).ajaxStart(function() {   $("#loading").show(); }).ajaxStop(function() {   $("#loading").hide(); });

Fatal error: Can't use method return value in write context in ci

Replace the first if statement with if( ! $this->session->userdata('user_id') ) . The empty function check if a variable is empty but userdata is a function. Additionally, for your information, according to the CodeIgniter documentation , the userdata function returns FALSE if the item doesn't exist, which means that if user_id doesn't exist in your session, the code in the else will be executed. ref: https://stackoverflow.com/questions/6730216/cant-use-method-return-value-in-write-context

youtube vertical playlist responsive in jquery

https://codepen.io/derwinsadiwa/pen/obbjdx

show category name in url in custom post type single page wordpress

function create_listing_post_type() { register_post_type( 'listing', array( 'labels' => array( 'name' => esc_html__('Listings', 'shiksha-aadhar-list'), 'singular_name' => esc_html__('Listing', 'shiksha-aadhar-list'), 'add_new' => 'Add New', 'add_new_item' => 'Add New Listing', 'edit_item' => 'Edit Listing', 'new_item' => 'New Listing', 'view_item' => 'View Listing', 'search_items' => 'Search Listings', 'not_found' =>  'Nothing Found', 'not_found_in_trash' => 'Nothing found in the Trash', 'parent_item_colon' => '' ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'menu_ic...

frontend image update code in wordpress

<?php /* Template Name: Update Listing */ get_header(); ?> <?php $current_postid=''; $user_id=''; if(isset($_GET['current_postid'])) {    $current_postid=$_GET['current_postid'];    $user_id = get_post_field( 'post_author', $_GET['current_postid'] ); } ?> <?php  $current_postid=$_GET['current_postid']; if(isset($_POST['post_update'])) {  /* image uplaod code start  */ require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); $uploaddir = wp_upload_dir(); $select_attachmentID=''; $select_attachmentID=get_post_meta($_GET['current_postid'],'_thumbnail_id',true); $featured_attached_path = get_attached_file( $_POST['_thumbnail_id'] ); $post_attachment=$_FILES['post_attachme...

last char remove from string in jquery

<script type="text/javascript">       jQuery(document).ready(function($){         var paramVal = $.trim($(".post_tags").val());         var readElem = paramVal.slice(-1);         if (readElem == ',') {         paramVal= paramVal.slice(0, -1);        $(".post_tags").val(paramVal);        var post_tag=$(".post_tags").val();          }       });       </script>

How To Read JSON Data Response Using PHP?

Example JSON Response $json_data = '{       "stat": "ok",       "profile": {         "providerName": "testing",         "identifier": "http://testing.com/58263223",         "displayName": "testing 1",         "preferredUsername": "testing 2",         "name": {           "formatted": "testing"         },         "url": "http://testing.com/testing/",         "photo": "https://securecdn.testing.com/uploads/users/5826/3223/avatar32.jpg?1373393837",         "providerSpecifier": "testing"       }     }'; Alternative 1 (returns object format) $data = json_decode($json_data); echo $data->profile->displayName; // outputs testing 1 echo $data->profile->preferredUsername;// outputs testing 2 Alternative 2...

get date from datepicker in jquery

 var inputdate = $('#inputDate').datepicker({ dateFormat: 'dd-mm-yy' }).val();

multiple WordPress solution reference url

http://vasashreya.blogspot.com/