Plugin Options not saving options and doesn’t work

You aren’t returning data from the sanitize function: function kns_sanitize_options( $input ) { $input[‘option1’] = sanitize_text_field( $input[‘option1’] ); $input[‘option2’] = sanitize_text_field( $input[‘option2’] ); } There is therefore nothing to save. Try: function kns_sanitize_options( $input ) { $input[‘option1’] = sanitize_text_field( $input[‘option1’] ); $input[‘option2’] = sanitize_text_field( $input[‘option2′] ); return $input; } Secondly, you’ve registered the name of … Read more

how to request a script more than once in wordpress

When you’re using wp_register/enqueue_script(), you’re basically pushing an element to an array named global $wp_scripts. Therefore you can’t echo something twice as WordPress successfully prevents scripts being registered or added multiple times. The reason is easy: Else, every plugin that registers or enqueues jQuery (or uses it as dependency) would add another instance. Which would … Read more

Undefined is_user_logged_in() error with Plugin Query code

require_once( wp_normalize_path(ABSPATH).’wp-load.php’); class Your_Plugin_Class { private $is_user_logged_in; add_action(‘init’, function(){ $this-> is_user_logged_in = is_user_logged_in(); echo ‘is_user_logged_in’.$this->is_user_logged_in; }); add_filter(‘woocommerce_billing_fields-2’,array( $this, ‘add_billing_field’ )); } public function add_billing_field( $fields = array() ) { if ( $this->is_user_logged_in ){ echo ‘add_billing_field’.$this->is_user_logged_in; return $fields; }else{ echo ‘add_billing_field’.$this->is_user_logged_in; } } }

how can i show a google map in custom post type

$prop_mapaddress contains your textfield value: <?php if(isset($prop_mapaddress)) { global $post; global $wpdb; $fromat_address = trim($prop_mapaddress); $fromat_address = str_replace(” “,”+”,$fromat_address); $address_obj = file_get_contents(“http://maps.googleapis.com/maps/api/geocode/json?address=”.$fromat_address.”&sensor=false”); $address_obj =json_decode($address_obj); $latitude = $address_obj->results[0]->geometry->location->lat; $longitude = $address_obj->results[0]->geometry->location->lng; ?> <script> var geocoder; var map; var lat = “<?php echo $latitude ?>”; var lng = “<?php echo $longitude; ?>”; function initialize() { geocoder = … Read more

Toolbar Hidden in a Virtual Page

The admin bar is initialized on template_redirect. You must be short-circuiting that. The quick and dirty method would be to run _wp_admin_bar_init(); near the top of your page. add_filter(‘wp_title’, function($title, $sep, $seplocation) { return ‘Register’; }, 10, 2); _wp_admin_bar_init(); // <- this <- get_header(); get_template_part(‘includes/breadcrumbs’); get_template_part(‘includes/top_info’); It would be somewhat neater to simply hook your … Read more