Using a variable in is_page(array())
In is_page you are passing an array with one element that is also an array. Since $result is already an array, you should do if ( is_page( $result ) ){
In is_page you are passing an array with one element that is also an array. Since $result is already an array, you should do if ( is_page( $result ) ){
Here is an example of adding custom rewrite rule to WordPress. For instance, you have a link http://website.com/1/ that would like WordPress interprets internally as http://website.com?tl=1 But for tl you have mentioned, I am not sure what is your settings. So I assume tl is working in your system. Because WP default parameter is p … Read more
Globals are generally discourgaged. You can use define instead. <?php define(“FILM_LABEL”, “Films”); define(“SHOW_LABEL”, “Shows”); function CreatePostTypes() { register_post_type( FILM_LABEL, GenerateFilmType( FILM_LABEL ) ); register_post_type( SHOW_LABEL, GenerateFilmType( SHOW_LABEL ) ); } add_action( ‘init’, ‘CreatePostTypes’ );
Your array definitions aren’t correct. This… elseif($_REQUEST[“price”] == 20){$price = “array( ’19’, ’20’ )”;} … creates a literal string that reads “array( ’19’, ’20’ )”. Remove the quotes. elseif($_REQUEST[“price”] == 20){$price = array( ’19’, ’20’ );} That should give you PHP arrays.
explode will be your best option. WordPress has a few built in functions to handle arrays of function arguments (wp_parse_args and shortcode_atts for example), but nothing relating to splitting a string and iterating the result. It’s not entierly clear to me what you are trying to achieve, but let’s say you were trying to get … Read more
Use wp_localize_script: wp_enqueue_script(‘YOUR_SCRIPT_HANDLE’); $object = array( ‘zoom’ => get_option(‘map_zoom’), ‘longitude’ => get_option(‘map_longitude’), ‘latitude’ => get_option(‘map_latitude’), ); wp_localize_script(‘YOUR_SCRIPT_HANDLE’, ‘JSObject’, $object); And then use it in your JS file like JSObject.zoom and the like.
Uing OOP for your plugin it’s very easy. class MyPlugin { static $flag; static function function_a() { self::$flag = ‘a value’; } static function function_b() { if ( ! is_null(self::$flag) ) echo self::$flag; // echo ‘A Value’; } } add_action(‘plugins_loaded’, array(‘MyPlugin’, ‘function_a’) ); add_action(‘init’, array(‘MyPlugin’, ‘function_b’) ); Not using OOP you can use global variables. … Read more
In the default usage this is impossible due to the nature of the default comment walker which always directly outputs. But the function allows to provide a custom walker. Further reading about custom walkers: Codex Class reference example custom walker class You could also use output buffering to save it into a variable (this is … Read more
You need a filter not an action. Something like this (notes are commented into the code. You have a few PHP errors that you need to correct): function signup_validate_insert($post){ $errors = false; if (isset($post[‘submit_msg’])) { // validate , insert into database } return $errors; } add_filter(‘signup_insert’, ‘signup_validate_insert’); $errors = apply_filters(‘signup_insert’, $_POST); if((!empty($errors))){ // $errors is … Read more
You should prefer the uninstall hook over the file if your main plugin doesn’t have side effects (outputs html or writes to file/DB automatically when loaded). IMO there is too much risk (i.e. non zero) of doing the uninstall.php code wrong and open the file to direct execution from the outside. This also help in … Read more