Web Development & WordPress

Associative array to JSON or Serialised conversion : PHP

Code:

<?php
$customer= [
"name"=>"Tommy Jason",
"age" => 45,
"sex" => "Male",
"location" => "USA"
];
print_r($customer);
echo "Serialized: <br>";
$serializedCustomer =serialize($customer);
echo $serializedCustomer;
echo "<br>";
echo "Unserialized: <br>";
$unserializedCustomer =unserialize($serializedCustomer);
print_r($unserializedCustomer);
echo "<br>";
echo "JSon Encoded<br>";
echo $jsonEncoded = json_encode($customer);
echo "<br>";
echo "Json Decoded --converted to object <br>";
$jsonDecoded= json_decode($jsonEncoded);
print_r($jsonDecoded);
echo "<br>Json Decoded --converted to Array <br>";
$jsonDecoded= json_decode($jsonEncoded,true);
print_r($jsonDecoded);
echo "<br>";

?>
Continue reading “Associative array to JSON or Serialised conversion : PHP”
Web Development & WordPress

PHP: Multidimensional Array and to show its value

Code:

<?php
$students=[
    '12'=>'Tom',
    '13'=>'Shib',
    '14'=>[
        '12'=>'Tom Spanish',
        '13'=>'Shib Spanish'
    ]
];
var_dump($students);
echo "<br>";

print_r($students);
echo "<br>";

echo $students["14"]["13"];
echo "<br>";
$food=array(
    "vegetables" => "tomato,potato",
    "frutis" => "apple, banana",
    "drinks" => array(
        "soft"=>"coke,fanta",
        "beverage" => "x,y,z",
    )
);

print_r($food);
echo "<br>";
echo $food["drinks"]["soft"];
?>
Continue reading “PHP: Multidimensional Array and to show its value”
Web Development & WordPress

Resolving WP Touch Pro Mobile View Conflict with W3 Total Cache: Fixing Desktop Cache Display Issue

If you are using both the W3 Total Cache and WP Touch Pro plugins for optimizing your site’s performance and mobile view respectively, you may encounter a conflict where WP Touch Pro stops displaying the mobile view and instead shows the cached desktop version.

Here is the Solution

Continue reading “Resolving WP Touch Pro Mobile View Conflict with W3 Total Cache: Fixing Desktop Cache Display Issue”
Web Development & WordPress

Add Social Icons at the end of blog post in Smart Theme v3 by Optimizepress

If you are using Smart Theme V3 by Optimizepress and you are searching to add some basic social icons at the end of blog post ( which you edited using Optimizepress builder), then use the code i shared here. It will be looked like this ( almost similar)

Continue reading “Add Social Icons at the end of blog post in Smart Theme v3 by Optimizepress”
Web Development & WordPress

WordPress free theme for cooking or gardening or healthy living : Modification and Make your site live

Sapor is a free wordpress theme which you can use for your cooking or gardening or healthy living blog site. Here I am sharing you css customization which you can use to customize or style it if you want to use the theme.

Download Sapor Theme

Sapor Theme Demo to get idea how it looks

Continue reading “WordPress free theme for cooking or gardening or healthy living : Modification and Make your site live”
Vedic Astrology Insights

Mercury in 8th house Precautions

** This contents are collected from my Guru’s (Deepanshu Giri) facebook page Lunarastro . The post is written by Nitin Bhatt . So these contents are for learning and research purpose only. I will gradually Update it.

As we know in astrology Mercury is communication and 8th house is Death. So Mercury in 8th  is the bearer of the bad news. Native may have committed sin of giving someone bad news just for joke, as 8th house is death, breaks and mercury represents communication, humour, so in this life also native will get habit of uncontrollable laugh, miscommunication at wrong time and even speaking Ill of the dead. 

That is why writing obituary for ancestors and write  and communicate good things about them will ward off negative energy of the Mercury in the 8th house. 

Also Mercury in 8th house shows incomplete rituals of death in family.

Web Development & WordPress

New User Registration with image upload Facility : WordPress

Here I am sharing you template file and the related functions.php file code to register a wordpress user ( user role is Editor)

The template is doing the following to register a new wordpress user

  1. Upload image
  2. Send mail to Admin and Registered user both after successful registration
  3. Saving the profile or uploaded image in /wp-content/uploads/USER_ID
  4. Redirect to a url ( slug is used in the code) after successful registration
Continue reading “New User Registration with image upload Facility : WordPress”
Web Development & WordPress

Author ( user role ) can only see his own uploaded images without making advance custom fields hidden

Generally , due to this code $wp_query->set(‘author’, $current_user->ID); the custom fields of Advanced Custom Fields ( acf ) got hidden. So i have used this following code to solve the issue. So if you use this code in function.php or using code snippet plugins, Author can see only his uploaded images instead of all users image.

 function restrict_author_media_library($wp_query) {
    if (  $wp_query->get('post_type') == 'attachment' && current_user_can('author')) {
        $current_user = wp_get_current_user();
        $wp_query->set('author', $current_user->ID);
    }
}

add_action('pre_get_posts', 'restrict_author_media_library');