Prevent plugin from deleting important directories

To answer my own question here is what I’ve found for the sake of keeping questions answered. What this does is copying the important directory before upgrade and recovering it after upgrade: function my_dir_copy($source, $dest) { if (is_link($source)) { return symlink(readlink($source), $dest); } if (is_file($source)) { return copy($source, $dest); } if (!is_dir($dest)) { mkdir($dest); } … Read more

Add Submenu Link in add_submenu_page That Opens in a New Window

This has to be solved: with an unconventional submenu manipulation, provided by @t31os in this Answer and some jQuery add_action( ‘admin_menu’, ‘wpse_66020_admin_menu_new_item’ ); add_action( ‘admin_head’, ‘wpse_66020_add_jquery’ ); function wpse_66020_admin_menu_new_item() { global $submenu; $submenu[‘index.php’][500] = array( ‘<div id=”wpse-66020″>Go to WPSE</div>’ , ‘manage_options’ , ‘https://wordpress.stackexchange.com/’ ); } function wpse_66020_add_jquery() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $(‘#wpse-66020’).parent().attr(‘target’,’_blank’); … Read more

using get_option to add a different js

You had an extra ( before get_option and the if statement syntax was wrong. Here is the revised code: add_action(‘wp_footer’,’isotope_vpl_set_style’); function isotope_vpl_set_style() { $style = get_option(‘damien_style’); if($style == “isotope”) { include(“inc/myfile.js”); } }

How to redirect to action on custom page within admin section

Get the url of a specific admin page (e.g. the settings page (options-general.php)): admin_url( ‘options-general.php’ ) Codex admin_url() Adding query arguments to an url: $params = array( ‘page’ => $_REQUEST[‘page’], ‘action’ => ‘edit’, ‘rls_element’ => $item[‘rls_name’] ); $url = add_query_arg( $params, $org_url ); Codex add_query_arg() Put a and b together: $params = array( ‘page’ => … Read more

Get the link text

You can use posts custom fields to store a custom continue reading text for each post, and then use that value in the_content_more_link filter. For example you might have a custom field with meta key of continue_reading to enable users to specify the custom Read More text, and use that value like: add_filter(‘the_content_more_link’, ‘ad_contiue_reading_text’,10,2); function … Read more

How to List Thumbnails based on Custom Categories

You need to use custom post and make the categorys there and align the thumbnails in each post. <?php // query post type */*/ global $post; $args = array( ‘post_type’ => ‘YOUR-POST-TYPE-HERE’, ‘cat’ => $category, ‘suppress_filters’ => ‘0’, ‘numberposts’ =>’-1′, ‘orderby’ => ‘title’, ‘order’ => ‘asc’, ‘post_status’ => ‘publish’ ); $myposts = get_posts( $args ); … Read more