Enqueue a file that’s not js or css

You could also look to create a special CSS file that you setup an htaccess rewrite rule for. For example wp-content/yourtheme/custom.css And then add a rule in your htaccess: RewriteEngine On RewriteRule ^/wp-content/yourtheme/custom.css$ /wp-content/yourtheme/styles.php [L] You can then call wp-load inside this styles.php file, do any sort of logic required, before outputting your custom css … Read more

Custom Post Type Object – Undefined Variables

Looks like some minor confusion here and syntax issues. Bad: You’re including the $ sign when setting property values. // Set Variables $this->$post_type_name = strtolower( str_replace( ‘ ‘,’_’, $name) ); $this->$post_type_args = $args; $this->$post_type_lables = $labels; Good: Omit the $ once you’ve declared them. // Set Variables $this->post_type_name = strtolower( str_replace( ‘ ‘,’_’, $name) ); … Read more

Problem with display data from get_option

You inserting the value of the get_option(‘go_to_top_or_bottom’);as a property in the $this->options so when you actual try to print it like this print_r($this->options[‘turn_on’]);you get the index error because this is a property!!! Correct way will be $this->options[‘turn_on’]=get_option(‘go_to_top_or_bottom’); Update I see that the $options is a private meaning you cannot access it outside of the class. … Read more

Hide one specific woocoomerce product

This code is tested and works fine on a fresh WP and WooCommerce installation. if ( !is_user_logged_in()) { function exclude_product_from_users($q){ $current_user = wp_get_current_user(); $prodcuts_ids = array(648); $q->set( ‘post__not_in’, $prodcuts_ids ); } add_action( ‘woocommerce_product_query’, ‘exclude_product_from_users’ ); function return_from_product_page(){ global $post; $prodcuts_ids = array(648); if(in_array( $post->ID , $prodcuts_ids)){ wp_redirect(home_url(“https://wordpress.stackexchange.com/”)); exit(); } } add_action(‘wp’, ‘return_from_product_page’); }

Asynchronous request in wordpress

Your AJAX URL varaible is different in your PHP and your JS. In your JS you refer to ajax_url: url: modallist.ajax_url, But the variable defined in PHP is ajaxurl: ‘ajaxurl’ => admin_url(‘admin-ajax.php’) , This is why you’re getting the full admin page as a response. Your request is going to the current page because there … Read more