add post meta box and save it to db

 //adding meta box to each post type for auto notifications add_action(‘admin_init’,‘add_custom_fields’); function add_custom_fields( ) { $screens = get_post_types(); foreach ( $screens as $screen ) { add_meta_box( ‘pnr-auto-push-notifications’, ‘Push Notification Reloaded’, ‘pnr_auto_push_notifications’, $screen, ‘side’, ‘high’, ); } } function pnr_auto_push_notifications($post){ $notification_status = get_post_meta( $post->ID, ‘pnr-auto-push-notifications’,true); ?> <input type=“checkbox” name=“auto_push_notifications” id=“auto_push_notifications” <?php if($notification_status == ‘on’) echo ‘checked’?> …

add post meta box and save it to db Read More »

add custom post type in wordpress

  /* * Creating a function to create our CPT */ function custom_post_type() { // Set UI labels for Custom Post Type $labels = array( ‘name’ => _x( ‘Movies’, ‘Post Type General Name’, ‘twentytwenty’ ), ‘singular_name’ => _x( ‘Movie’, ‘Post Type Singular Name’, ‘twentytwenty’ ), ‘menu_name’ => __( ‘Movies’, ‘twentytwenty’ ), ‘parent_item_colon’ => __( ‘Parent …

add custom post type in wordpress Read More »

wordpress add option checkbox and retrive data

 <form method=“post” action=“”> <span>Select languages</span><br/> <input type=“checkbox” name=‘lang[]’ value=“PHP”> PHP <br/> <input type=“checkbox” name=‘lang[]’ value=“JavaScript”> JavaScript <br/> <input type=“checkbox” name=‘lang[]’ value=“jQuery”> jQuery <br/> <input type=“checkbox” name=‘lang[]’ value=“Angular JS”> Angular JS <br/> <input type=“submit” value=“Submit” name=“submit”> </form> <?php if(isset($_POST[‘submit’])){ if(!empty($_POST[‘lang’])) { foreach($_POST[‘lang’] as $value){ echo “value : “.$value.‘<br/>’; } } update_option( ‘pnr_post_type’,$_POST[‘lang’] ); } ?> get …

wordpress add option checkbox and retrive data Read More »

wordpress auto send email to admin on page /post update or publish

 //post and page updated -send email to admin function pnr_auto_send_email( $post_id ) { global $post; // If this is just a revision, don’t send the email. if( $post->post_type == ‘post’){ $post_title = get_the_title( $post_id ); $post_url = get_permalink( $post_id ); if ( $post->post_date != $post->post_modified) { //update $subject = ‘A post has been updated’; } …

wordpress auto send email to admin on page /post update or publish Read More »

GET Location from ip in php

   $ip = ‘117.197.234.146’; $details = json_decode(file_get_contents(“http://ipinfo.io/{$ip}/json”)); echo $details->city; // -> “Mountain View” return stdClass Object( [ip] => 117.197.234.146 [city] => Bhubaneshwar [region] => Odisha [country] => IN [loc] => 20.2724,85.8338 [org] => AS9829 National Internet Backbone [postal] => 752115 [timezone] => Asia/Kolkata [readme] => https://ipinfo.io/missingauth)

make stickey div in wordpress plugin

 <style> .kanha { top: 32px; } </style> <div class=“container mt-3”> <!– welcome message –> <div class=” sticky-top alert alert-warning kanha” role=“alert”> <h4 class=“alert-heading”><?php _e(‘Welcome to’,‘push-notifications-reloaded’);?> <b><?php _e(‘Push Notifications Reloaded’,‘push-notifications-reloaded’);?> </b> <span>Help</span> </h4> <p><?php _e(‘A simple & easy way to send ‘,‘push-notifications-reloaded’);?> <b><?php _e(‘Push Notifications.’,‘push-notifications-reloaded’);?></b> </p> </div> </div>

php curl delete

 public function curl_delete($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “DELETE”); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $result;}