Last active
October 10, 2020 12:36
-
-
Save tsbega/df5a034f68bf55b6a6a017a68279473e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Meta Tags Generator | |
remove_action('wp_head', 'wp_generator'); | |
remove_action('wp_head', 'woo_version'); | |
// Retirando a barra do admin no wordpress | |
add_filter( 'show_admin_bar' , 'my_function_admin_bar'); | |
function my_function_admin_bar(){ | |
return false; | |
} | |
// Suporte ao Advanced Custom Fields | |
define( 'ACF_LITE', true ); | |
include_once('advanced-custom-fields/acf.php'); | |
// Suporte ao Woocommerce | |
add_action( 'after_setup_theme', 'woocommerce_support' ); | |
function woocommerce_support() { | |
add_theme_support( 'woocommerce' ); | |
} | |
//Removendo menus wp admin | |
function remove_menus(){ | |
remove_menu_page( 'index.php' ); //Dashboard | |
remove_menu_page( 'jetpack' ); //Jetpack* | |
remove_menu_page( 'edit.php' ); //Posts | |
remove_menu_page( 'upload.php' ); //Media | |
remove_menu_page( 'edit.php?post_type=page' ); //Pages | |
remove_menu_page( 'edit-comments.php' ); //Comments | |
remove_menu_page( 'themes.php' ); //Appearance | |
remove_menu_page( 'plugins.php' ); //Plugins | |
remove_menu_page( 'users.php' ); //Users | |
remove_menu_page( 'tools.php' ); //Tools | |
remove_menu_page( 'options-general.php' ); //Settings | |
} | |
add_action( 'admin_menu', 'remove_menus' ); | |
// Modelo de Plugin (Function) | |
add_action( 'init', 'ewp_funcao_a_chamar' ); | |
function ewp_funcao_a_chamar() { | |
//any code | |
} | |
// Plugin dos Clientes | |
add_option( "ov_db_version", "1.0" ); | |
function clients_install(){ | |
global $wpdb; | |
global $ov_db_version; | |
$table_name = $wpdb->prefix . "consult_client"; | |
$charset_collate = $wpdb->get_chaset_collate(); | |
$sql = "CREATE TABLE $table_name ( | |
id mediumint(9) NOT NULL AUTO_INCREMENT, | |
name tinytext NOT NULL, | |
birthday date DEFAULT '00-00-0000' NOT NULL, | |
email tinytext NOT NULL, | |
PRIMARY KEY (id) | |
) $charset_collate;"; | |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
dbDelta( $sql ); | |
add_option( "ov_db_version", "$ov_db_version" ); | |
} | |
// Desabilitando o WP-Embed | |
function my_deregister_scripts(){ | |
wp_deregister_script( 'wp-embed' ); | |
} | |
add_action( 'wp_footer', 'my_deregister_scripts' ); | |
// Desabilitando a API JSON | |
function remove_json_api () { | |
// Remove the REST API lines from the HTML Header | |
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ); | |
// Remove the REST API endpoint. | |
remove_action( 'rest_api_init', 'wp_oembed_register_route' ); | |
// Turn off oEmbed auto discovery. | |
add_filter( 'embed_oembed_discover', '__return_false' ); | |
// Don't filter oEmbed results. | |
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); | |
// Remove oEmbed discovery links. | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); | |
// Remove oEmbed-specific JavaScript from the front-end and back-end. | |
remove_action( 'wp_head', 'wp_oembed_add_host_js' ); | |
// Remove all embeds rewrite rules. | |
add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' ); | |
} | |
add_action( 'after_setup_theme', 'remove_json_api' ); | |
// Remove Link Shortlink in WP Head | |
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); | |
/** | |
* Dequeue jQuery Migrate script in WordPress. | |
*/ | |
function isa_remove_jquery_migrate( &$scripts) { | |
if(!is_admin()) { | |
$scripts->remove( 'jquery'); | |
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' ); | |
} | |
} | |
add_filter( 'wp_default_scripts', 'isa_remove_jquery_migrate' ); | |
// Adicionando a possibilidade de carregar o style.min.css ou o style.min | |
add_action( 'wp_head', 'style_or_min_style'); | |
function style_or_min_style() { | |
$located = locate_template( 'style.min.css' ); | |
if ($located != '' ) { | |
echo '<link rel="stylesheet" type="text/css" href="' . get_stylesheet_directory_uri() . '/style.min.css" />'; | |
} else { | |
echo '<link rel="stylesheet" type="text/css" href="' . get_stylesheet_directory_uri() . '/style.css" />'; | |
} | |
} | |
/** | |
* Optimize WooCommerce Scripts | |
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 ); | |
function child_manage_woocommerce_styles() { | |
//remove generator meta tag | |
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); | |
//first check that woo exists to prevent fatal errors | |
if ( function_exists( 'is_woocommerce' ) ) { | |
//dequeue scripts and styles | |
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { | |
wp_dequeue_style( 'woocommerce_frontend_styles' ); | |
wp_dequeue_style( 'woocommerce_fancybox_styles' ); | |
wp_dequeue_style( 'woocommerce_chosen_styles' ); | |
wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); | |
wp_dequeue_script( 'wc_price_slider' ); | |
wp_dequeue_script( 'wc-single-product' ); | |
wp_dequeue_script( 'wc-add-to-cart' ); | |
wp_dequeue_script( 'wc-cart-fragments' ); | |
wp_dequeue_script( 'wc-checkout' ); | |
wp_dequeue_script( 'wc-add-to-cart-variation' ); | |
wp_dequeue_script( 'wc-single-product' ); | |
wp_dequeue_script( 'wc-cart' ); | |
wp_dequeue_script( 'wc-chosen' ); | |
wp_dequeue_script( 'woocommerce' ); | |
wp_dequeue_script( 'prettyPhoto' ); | |
wp_dequeue_script( 'prettyPhoto-init' ); | |
wp_dequeue_script( 'jquery-blockui' ); | |
wp_dequeue_script( 'jquery-placeholder' ); | |
wp_dequeue_script( 'fancybox' ); | |
wp_dequeue_script( 'jqueryui' ); | |
} | |
} | |
} | |
//Desabilitando o acesso ao WP-REST-JSON | |
add_filter( 'rest_authentication_errors', 'ultimatewoo_disable_rest_api' ); | |
function ultimatewoo_disable_rest_api( $access ) { | |
return new WP_Error( 'rest_disabled', __( 'The REST API on this site has been disabled.' ), array( 'status' => rest_authorization_required_code() ) ); | |
} | |
// Adicionando suporte ao WooCommerce | |
add_theme_support( 'woocommerce' ); | |
// Removendo CSS do WooCommerce | |
define('WOOCOMMERCE_USE_CSS', false); | |
// Removendo a seção "Reviews" | |
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 ); | |
function wcs_woo_remove_reviews_tab($tabs) { | |
unset($tabs['reviews']); | |
return $tabs; | |
} | |
// Removendo o Wp-Emoji | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
// Removendo o XML-RPC | |
add_filter('xmlrpc_enabled', '__return_false'); | |
add_filter('xmlrpc_enabled', '__return_false'); | |
add_filter( 'wp_headers', 'disable_x_pingback' ); | |
function disable_x_pingback( $headers ) { | |
unset( $headers['X-Pingback'] ); | |
return $headers; | |
} | |
// Removendo o RSS Feed | |
function wpb_disable_feed() { | |
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') ); | |
} | |
add_action('do_feed', 'wpb_disable_feed', 1); | |
add_action('do_feed_rdf', 'wpb_disable_feed', 1); | |
add_action('do_feed_rss', 'wpb_disable_feed', 1); | |
add_action('do_feed_rss2', 'wpb_disable_feed', 1); | |
add_action('do_feed_atom', 'wpb_disable_feed', 1); | |
add_action('do_feed_rss2_comments', 'wpb_disable_feed', 1); | |
add_action('do_feed_atom_comments', 'wpb_disable_feed', 1); | |
// Removendo o Meta Generator | |
function wpbeginner_remove_version() { | |
return ''; | |
} | |
add_filter('the_generator', 'wpbeginner_remove_version'); | |
//Removendo as barras de todos os usuarios | |
function my_function_admin_bar(){ | |
return false; | |
} | |
add_filter( 'show_admin_bar' , 'my_function_admin_bar'); | |
//Caso o usuário não consiga fazer o login no frontend ele será redirecionado para a mesma tela | |
add_action( 'wp_login_failed', 'my_front_end_login_fail' ); // hook failed login | |
function my_front_end_login_fail( $username ) { | |
$referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from? | |
// if there's a valid referrer, and it's not the default log-in screen | |
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) { | |
wp_redirect( $referrer . '?login=failed' ); // let's append some information (login=failed) to the URL for the theme to use | |
exit; | |
} else { | |
echo "<script type='javascript'>alert('Email enviado com Sucesso!');"; | |
} | |
} | |
function wc_ninja_remove_password_strength() { | |
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) { | |
wp_dequeue_script( 'wc-password-strength-meter' ); | |
} | |
} | |
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 ); | |
add_filter('woocommerce_ajax_get_endpoint', 'rsssl_redirect_ajax'); | |
function rsssl_redirect_ajax($url){ | |
$url = str_replace( 'http://', 'https://', $url ); | |
return $url; | |
} | |
// otimização | |
// // Remove password strength | |
function wc_ninja_remove_password_strength() { | |
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) { | |
wp_dequeue_script( 'wc-password-strength-meter' ); | |
} | |
} | |
// Remove query string from static files | |
function remove_cssjs_ver( $src ) { | |
if( strpos( $src, '?ver=' ) ) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} | |
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 ); | |
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment