Enter your keyword

Blogs

How to Disable Default Dashboard Widgets in WordPress

function disable_default_dashboard_widgets() {
  global $wp_meta_boxes;
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
  // bbpress
  unset($wp_meta_boxes['dashboard']['normal']['core']['bbp-dashboard-right-now']);
  // yoast seo
  unset($wp_meta_boxes['dashboard']['normal']['core']['yoast_db_widget']);
  // gravity forms
  unset($wp_meta_boxes['dashboard']['normal']['core']['rg_forms_dashboard']);
}
add_action('wp_dashboard_setup', 'disable_default_dashboard_widgets', 999);

How To Remove Links From WordPress Admin Toolbar

To remove the links you just need to add the following function to your functions.php file and add a new action into the wp_before_admin_bar_render function.

function remove_admin_bar_links() {
    global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');   // Remove the WordPress logo
$wp_admin_bar->remove_menu('about');     // Remove the about WordPress link
$wp_admin_bar->remove_menu('wporg');     // Remove the WordPress.org link
$wp_admin_bar->remove_menu('documentation'); // Remove the documentation link
$wp_admin_bar->remove_menu('support-forums');  // Remove the support forums link
$wp_admin_bar->remove_menu('feedback');       // Remove the feedback link
$wp_admin_bar->remove_menu('site-name');      // Remove the site name menu
$wp_admin_bar->remove_menu('view-site');      // Remove the view site link
$wp_admin_bar->remove_menu('updates');        // Remove the updates link
$wp_admin_bar->remove_menu('comments');       // Remove the comments link
$wp_admin_bar->remove_menu('new-content');    // Remove the content link
$wp_admin_bar->remove_menu('w3tc');  //w3 total cache remove the performance link
$wp_admin_bar->remove_menu('my-account'); // Remove the user details tab
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

How to Add Favicon Icon in WordPress

function favicon_admin(){
echo '<link rel="shortcut icon" href="'.get_bloginfo('stylesheet_directory').'/favicon.ico" />';
}
add_action('admin_head','favicon_admin'); 

How to Disable the Plugin and Theme Editor

Access to plugin and theme code is readily available in the WordPress dashboard. One thing you can do to protect the site from tinkering is to disable the both of these editors. You can do this in under a minute. Open your wp-config.php file and add the following constant:

define('DISALLOW_FILE_EDIT',true);

How to Rename WP-Content Folder in WordPress

Open your wp-config.php file and add the following constant:

define ('WP_CONTENT_DATA', 'data');  

define ('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_DATA) ; 

define ('WP_CONTENT_URL', site_url().WP_CONTENT_DATA);
  
define ('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
   
define ('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');

How to Disable all the Nags & Notifications in WordPress

Insert the following code the functions.php file of your active theme. This code disables all the updates notifications regarding plugins, themes & WordPress completely.

<?php
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
?>

How to Disable WordPress Plugin Update Notifications

Insert the following code to the functions.php file of your active theme. It will remove the update notifications of all the installed plugins.  

remove_action('load-update-core.php','wp_update_plugins');
add_filter('pre_site_transient_update_plugins','__return_null');

How to Add Multiple Input Fields Using jQuery

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>

<script>
$(document).ready(function() {
    var max_fields      = 10; //maximum input boxes allowed
    var wrapper         = $(".input_fields_wrap"); //Fields wrapper
    var add_button      = $(".add_field_button"); //Add button ID
   
    var x = 1; //initlal text box count
    $(add_button).click(function(e){ //on add input button click
        e.preventDefault();
        if(x < max_fields){ //max input box allowed
            x++; //text box increment
         $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
        }
    });
   
    $(wrapper).on("click",".remove_field", function(e){ //user click on remove text
        e.preventDefault(); $(this).parent('div').remove(); x--;
    })
});
</script>
<div class="input_fields_wrap"> <a href="#" class="add_field_button">Add More Fields</a>
  <div> <input type="text" name="mytext[]"> </div>
</div>

Window Full Screen jQuery Function

<script>
(function() {
    var
        fullScreenApi = {
            supportsFullScreen: false,
            nonNativeSupportsFullScreen: false,
            isFullScreen: function() { return false; },
            requestFullScreen: function() {},
            cancelFullScreen: function() {},
            fullScreenEventName: '',
            prefix: ''
        },
        browserPrefixes = 'webkit moz o ms khtml'.split(' ');
 
    // check for native support
    if (typeof document.cancelFullScreen != 'undefined') {
        fullScreenApi.supportsFullScreen = true;
    } else {
        // check for fullscreen support by vendor prefix
        for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
            fullScreenApi.prefix = browserPrefixes[i];
 
            if (typeof document[fullScreenApi.prefix + 'CancelFullScreen' ] != 'undefined' ) {
                fullScreenApi.supportsFullScreen = true;
 
                break;
            }
        }
    }
 
    // update methods to do something useful
    if (fullScreenApi.supportsFullScreen) {
        fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
 
        fullScreenApi.isFullScreen = function() {
            switch (this.prefix) {
                case '':
                    return document.fullScreen;
                case 'webkit':
                    return document.webkitIsFullScreen;
                default:
                    return document[this.prefix + 'FullScreen'];
            }
        }
        fullScreenApi.requestFullScreen = function(el) {
            return (this.prefix === '') ? el.requestFullScreen() : el[this.prefix + 'RequestFullScreen']();
        }
        fullScreenApi.cancelFullScreen = function(el) {
            return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen']();
        }
    }
    else if (typeof window.ActiveXObject !== "undefined") { // IE.
        fullScreenApi.nonNativeSupportsFullScreen = true;
        fullScreenApi.requestFullScreen = fullScreenApi.requestFullScreen = function (el) {
                var wscript = new ActiveXObject("WScript.Shell");
                if (wscript !== null) {
                    wscript.SendKeys("{F11}");
                }
        }
        fullScreenApi.isFullScreen = function() {
                return document.body.clientHeight == screen.height && document.body.clientWidth == screen.width;
        }
    }
 
    // jQuery plugin
    if (typeof jQuery != 'undefined') {
        jQuery.fn.requestFullScreen = function() {
 
            return this.each(function() {
                if (fullScreenApi.supportsFullScreen) {
                    fullScreenApi.requestFullScreen(this);
                }
            });
        };
    }
 
    // export api
    window.fullScreenApi = fullScreenApi;
})();


</script>
<button onClick="fullScreenApi.requestFullScreen(document.documentElement)" > Click to Window Full Screen </button>

How to use Scroll to Top function in jQuery

<script>
$(document).ready(function(){
  
  //Check to see if the window is top if not then display button
  $(window).scroll(function(){
    if ($(this).scrollTop() > 100) {
      $('.scrollToTop').fadeIn();
    } else {
      $('.scrollToTop').fadeOut();
    }
  });
  
  //Click event to scroll to top
  $('.scrollToTop').click(function(){
    $('html, body').animate({scrollTop : 0},800);
    return false;
  });
  
});
</script>

How to Replace the Widget in Genesis or WordPress

Step 1: First You will place the Unregistered Widget code in your function.php file

<?php
function remove_Featured_widget() {
  unregister_widget('Featured_Post');
}
add_action( 'widgets_init', 'remove_Featured_widget' );
?>

Step 2: Include the new widget file or function in your function.php than place Register widget function :

function Child_Featured_register_widgets() {
  register_widget( 'Child_Featured_Post' );
}
add_action( 'widgets_init', 'Child_Featured_register_widgets' );

Show Visual Composer in Admin Editor in WordPress

When Visual Composer Plugin is Activated and not showing the Editor in Visual Mode then below function place in your function.php file

function visual_composer_editor_display() {
   echo '<style type="text/css">
           .js .tmce-active .wp-editor-area{color: #000000!important}
           </style>';
}
add_action('admin_head', 'visual_composer_editor_display');

How to Remove Default Genesis Footer widgets

<?php /* Remove Genesis Footer Widgets in Admin Widgets Area */
 remove_theme_support( 'genesis-footer-widgets', 3 ); ?>
<?php
/* Remove Genesis Footer Widgets in Front end */
remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );
?>

How to Add new custom favicon icon in Genesis

<?php 
/** Add new custom favicon icon in Genesis */
add_filter( 'genesis_pre_load_favicon', 'custom_favicon' );
function custom_favicon( $favicon_url ) {
    return get_stylesheet_directory_uri().'/images/favicon.ico';
}
?>