Check if current page is wp-admin
You can test for roles with current_user_can(): if ( is_admin() && !current_user_can(‘administrator’) ) { // redirect }
You can test for roles with current_user_can(): if ( is_admin() && !current_user_can(‘administrator’) ) { // redirect }
WordPress uses GMT. The only way to get around that is to declare a new timezone after the header to use for your own purposes. Kind of a pain. Also see this answer: How to get WordPress Time Zone setting?
URL path can’t be passed to file_exists PHP: file_exists – Manual Use get_template_directory() or get_stylesheet_directory() instead: if(file_exists(get_template_directory()./path/file.css’)) as that returns server path
You will need to use style parameter to define the type of list. And to remove <br /> tags from the list, set parameter ‘echo’ => 0 and str_replace to remove <br /> tag from the output. $args = array( ‘orderby’ => ‘name’, ‘show_count’ => 0, ‘pad_counts’ => 0, ‘hierarchical’ => 1, ‘taxonomy’ => $tax, … Read more
You’re using the widget name and not i.d which is why it isn’t working. Change this: if (is_active_sidebar( ‘My_Widgtet_Area’ ) ) : ?> <div id=”widget-sidebar”> <ul> <?php dynamic_sidebar( ‘My_Widgtet_Area’ ); ?> </ul> To this: if (is_active_sidebar( ‘partner-slide’ ) ) : ?> <div id=”widget-sidebar”> <ul> <?php dynamic_sidebar( ‘partner-slide’ ); ?> </ul> The i.d in the template … Read more
You could work with a white-list and replace the regular expression with something more readable: add_filter( ‘nav_menu_css_class’, function( $classes ) { $allowed = [ ‘menu-item-has-children’, ‘current-menu-item’ ]; return array_intersect( $classes, $allowed ); }); That would make it easier to maintain the white-list too.
The WordPress codex states that “The file MUST be on the uploads directory”. I’ve added a line to move the uploaded file into the uploads directory and changed the guid path. if( isset( $_POST[‘submit’] ) ) { $filename = $_FILES[‘file’][‘name’]; $wp_filetype = wp_check_filetype( basename($filename), null ); $wp_upload_dir = wp_upload_dir(); // Move the uploaded file into … Read more
You have to hook into the wp_nav_menu_items filter to get the correct link with the nonce, as described here . An example of how to do that can be seen here https://gist.github.com/theukedge/6565746#file-gistfile1-php
The no no about loading wp-* files directly are reasonable when you are developing a WordPress plugin or theme, but if you are developing an external code that require WP (and that seems your case) than you must require that files, there is no alternatives. Consider that including wp-blog-header.php is needed when you need to … Read more
$.post(ajaxurl,{ action:’master_ajaxurl’, option: $(this).find(“option:selected”).val(), // use option also here }, function(data){ //adds the echoed response to our container // alert(data); $(“#details”).html(data); } ); Move action and functions into function.php file make some changes as commented add_action(‘wp_ajax_master_ajaxurl’, ‘master_ajaxurl’); add_action(‘wp_ajax_nopriv_master_ajaxurl’, ‘master_ajaxurl’); function master_ajaxurl() { $myOpt = $_POST[‘option’]; // use option instead of data echo bringDetails($myOpt); die(); } … Read more