Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2018
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.65 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Add your custom modifications here, this file will never be modified by an update.
  4.  *
  5.  * This file is included at the end of functions.php file.
  6.  *
  7.  * @since fluxus 1.0
  8.  */
  9.  
  10. /**
  11.  * Reorder Style Sheets in WordPress
  12.  * https://blog.calevans.com/2015/03/04/reordering-style-sheets-in-wordpress/
  13.  */
  14. function cal_adjuststylesheets() {
  15.         global $wp_styles;
  16.  
  17.         $keys=[];
  18.         $keys[] = 'responsive-lightbox-prettyphoto';
  19.         $keys[] = 'photoswipe'; // WooCommerce
  20.         $keys[] = 'photoswipe-default-skin'; // WooCommerce
  21.         $keys[] = 'select2'; // WooCommerce
  22.         $keys[] = 'woocommerce-inline-inline';
  23.         $keys[] = 'woocommerce-general';
  24.         $keys[] = 'woocommerce-smallscreen';
  25.         $keys[] = 'woocommerce-layout';
  26.         $keys[] = 'woocommerce-layout-inline';
  27.         $keys[] = 'wpdreams-asl-basic';
  28.         $keys[] = 'wpdreams-ajaxsearchlite';
  29.         $keys[] = 'social-logos';
  30.         $keys[] = 'jetpack_css';
  31.         $keys[] = 'fluxus-normalize';
  32.         $keys[] = 'fluxus-global';
  33.         $keys[] = 'fluxus-icons';
  34.         $keys[] = 'fluxus-style';
  35.         $keys[] = 'fluxus-grid';
  36.         $keys[] = 'fontello-icons';
  37.         $keys[] = 'fluxus-style';
  38.         $keys[] = 'fluxus-skin';
  39.         $keys[] = 'fluxus-responsive';
  40.         $keys[] = 'fluxus-customizer';
  41.         $keys[] = 'fluxus-user';
  42.  
  43.         foreach($keys as $currentKey) {
  44.             $keyToSplice = array_search($currentKey,$wp_styles->queue);
  45.  
  46.             if ($keyToSplice!==false && !is_null($keyToSplice)) {
  47.                 $elementToMove = array_splice($wp_styles->queue,$keyToSplice,1);
  48.                 $wp_styles->queue[] = $elementToMove[0];
  49.             }
  50.         }
  51.         return;
  52. }
  53.  
  54. add_action( 'wp_print_styles', 'cal_adjuststylesheets', 99 );
  55.  
  56. /**
  57.  * Disable Fluxus gallery
  58.  * https://themeforest.net/item/fluxus-portfolio-theme-for-photographers/3854385
  59.  */
  60. remove_filter( 'post_gallery', 'fluxus_shortcode_gallery', 2 );
  61.  
  62. /**
  63.  * Move Jetpack Sharing Buttons
  64.  * https://jetpack.com/2013/06/10/moving-sharing-icons/
  65.  */
  66. function jptweak_remove_share() {
  67.     remove_filter( 'the_content', 'sharing_display', 19 );
  68.     remove_filter( 'the_excerpt', 'sharing_display', 19 );
  69.     if ( class_exists( 'Jetpack_Likes' ) ) {
  70.         remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
  71.     }
  72. }
  73. add_action( 'loop_start', 'jptweak_remove_share' );
  74.  
  75. /**
  76. * Jetpack: add theme support for Responsive Videos.
  77. * https://jetpack.com/support/responsive-videos/
  78. */
  79. function jetpackme_responsive_videos_setup() {
  80.     add_theme_support( 'jetpack-responsive-videos' );
  81. }
  82. add_action( 'after_setup_theme', 'jetpackme_responsive_videos_setup' );
  83.  
  84. /**
  85. * Jetpack: remove Jetpack Related Posts on fluxus portfolio post type
  86. * https://wpteardown.com/remove-jetpacks-related-post-custom-post-types-cpt/
  87. */
  88. function afn_jetpack_singular_no_related_posts( $options ) {
  89.     if ( is_singular( 'fluxus_portfolio' ) ) {
  90.         $options['enabled'] = false;
  91.     }
  92.     return $options;
  93. }
  94. add_filter( 'jetpack_relatedposts_filter_options', 'afn_jetpack_singular_no_related_posts' );
  95.  
  96.  
  97. /**
  98.  * Modificaciones a WooCommerce
  99.  * https://docs.woocommerce.com/
  100.  */
  101.  
  102. // Adds WooCommerce theme support (https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/)
  103. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
  104. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
  105.  
  106. add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
  107. add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
  108.  
  109. function my_theme_wrapper_start() {
  110.     echo '<div id="main" class="site site-with-sidebar">';
  111.     echo '<div id="content" class="site-content">';
  112.         if(function_exists('bcn_display')) {
  113.             echo '<div class="bread-woo">';
  114.             bcn_display();
  115.             echo '</div>';
  116.         }
  117. }
  118.  
  119. function my_theme_wrapper_end() {
  120.     echo '</div>';
  121.     get_sidebar();
  122.     echo '</div>';
  123. }
  124.  
  125. add_action( 'after_setup_theme', 'woocommerce_support' );
  126. function woocommerce_support() {
  127.     add_theme_support( 'woocommerce' );
  128. }
  129.  
  130. // Compatibilidad con galerías de WordPress a partir de WooCommerce 3.0>
  131. add_action( 'after_setup_theme', 'yourtheme_setup' );
  132.  
  133. function yourtheme_setup() {
  134.     add_theme_support( 'wc-product-gallery-zoom' );
  135.     add_theme_support( 'wc-product-gallery-lightbox' );
  136.     add_theme_support( 'wc-product-gallery-slider' );
  137. }
  138.  
  139. // Remove WooCommerce breadcrumb (https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/#section-4)
  140. add_action( 'init', 'jk_remove_wc_breadcrumbs' );
  141. function jk_remove_wc_breadcrumbs() {
  142.     remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
  143. }
  144.  
  145. // Change WooCommerce currency symbol (https://docs.woocommerce.com/document/change-a-currency-symbol/ - https://wordpress.org/support/topic/gateways-currency-converter-module-is-overriding-my-custom-currency-symbol/#post-10601235)
  146. add_action( 'init', 'add_filter_change_existing_currency_symbol', PHP_INT_MAX );
  147. function add_filter_change_existing_currency_symbol() {
  148.     add_filter( 'woocommerce_currency_symbol', 'change_existing_currency_symbol', PHP_INT_MAX, 2 );
  149. }
  150. function change_existing_currency_symbol( $currency_symbol, $currency ) {
  151.     switch( $currency ) {
  152.         case 'ARS': $currency_symbol = 'ARS ';
  153.         break;
  154.  
  155.         case 'USD': $currency_symbol = 'US$ ';
  156.         break;
  157.     }
  158.     return $currency_symbol;
  159. }
  160.  
  161. // Remove the sorting dropdown from Woocommerce Categories (https://hirejordansmith.com/how-to-remove-the-woocommerce-results-count/)
  162. remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_catalog_ordering', 30 );
  163.  
  164. // Remove the result count from WooCommerce Categories
  165. remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_result_count', 20 );
  166.  
  167. // Remove "Add to Cart" Buttons on WooCommerce Shop Archives Page and Categories page (https://isabelcastillo.com/remove-add-to-cart-buttons-woocommerce)
  168. remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
  169.  
  170. // Remove page title from WooCommerce Shop and Categories pages (https://gist.github.com/corsonr/8703820)
  171. add_filter( 'woocommerce_show_page_title' , 'woo_hide_page_title' );
  172.  
  173. function woo_hide_page_title() {
  174.     return false;
  175. }
  176.  
  177. // Removes products count after Categories name (http://www.remicorson.com/woocommerce-remove-category-products-count/)
  178. add_filter( 'woocommerce_subcategory_count_html', 'woo_remove_category_products_count' );
  179.  
  180. function woo_remove_category_products_count() {
  181.     return;
  182. }
  183.  
  184. // Display 9 products per page (https://docs.woocommerce.com/document/change-number-of-products-displayed-per-page/)
  185. add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 9;' ), 20 );
  186.  
  187. // Change number of related products output (https://docs.woocommerce.com/document/change-number-of-related-products-output/)
  188. function woo_related_products_limit() {
  189.   global $product;
  190.    
  191.     $args['posts_per_page'] = 6;
  192.     return $args;
  193. }
  194. add_filter( 'woocommerce_output_related_products_args', 'jk_related_products_args' );
  195.   function jk_related_products_args( $args ) {
  196.     $args['posts_per_page'] = 3; // 3 related products
  197.     $args['columns'] = 3; // arranged in 3 columns
  198.     return $args;
  199. }
  200.  
  201. // Remove images in single product page (https://www.skyverge.com/blog/hide-woocommerce-product-image/)
  202. remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
  203.  
  204. // Change labels for Direct bank transfer payment method (https://wordpress.stackexchange.com/questions/77783/change-label-for-field-used-in-woo-commerce/77836#77836)
  205. function woocommerce_bacs_account_fields($translation, $text, $domain) {
  206.     if ($domain == 'woocommerce') {
  207.         switch ($text) {
  208.             case 'Sort code':
  209.                 $translation = 'Alias';
  210.                 break;
  211.  
  212.             case 'IBAN':
  213.                 $translation = 'CBU';
  214.                 break;
  215.  
  216.             case 'BIC':
  217.                 $translation = 'CUIT';
  218.                 break;
  219.         }
  220.     }
  221.  
  222.     return $translation;
  223. }
  224. add_filter('gettext', 'woocommerce_bacs_account_fields', 10, 3);
  225.  
  226. // Remove zoom and link to image file on single product page image (https://generatepress.com/forums/topic/remove-zoom-effect-on-woocommerce-product-image/#post-467379)
  227. function custom_single_product_image_html( $html, $post_id ) {
  228.     $post_thumbnail_id = get_post_thumbnail_id( $post_id );
  229.     return get_the_post_thumbnail( $post_thumbnail_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
  230. }
  231. add_filter('woocommerce_single_product_image_thumbnail_html', 'custom_single_product_image_html', 10, 2);
  232.  
  233. // Mueve las tabs hacia arriba de los botones de Jetpack Sharing (https://www.dariobf.com/cambiar-orden-elementos-producto-woocommerce/)
  234. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
  235. add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 30 );
  236.  
  237. // Mueve productos relacionados arriba de etiquetas
  238. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
  239. add_action( 'woocommerce_single_product_summary', 'woocommerce_output_related_products', 30 );
  240.  
  241. // Remove password strength check (https://iconicwp.com/blog/disable-password-strength-meter-woocommerce/)
  242. function iconic_remove_password_strength() {
  243.     wp_dequeue_script( 'wc-password-strength-meter' );
  244. }
  245. add_action( 'wp_print_scripts', 'iconic_remove_password_strength', 10 );
  246.  
  247. // Pone el resumen arriba del título
  248. remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
  249. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 0 );
  250.  
  251. // Hide categories by ID (https://www.tychesoftwares.com/hide-woocommerce-categories-shop/)
  252. function get_subcategory_terms( $terms, $taxonomies, $args ) {
  253.  
  254.     $new_terms  = array();
  255.     $hide_category  = array( 281 ); // Ids of the category you don't want to display on the shop page
  256.    
  257.       // if a product category and on the shop page
  258.     if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
  259.         foreach ( $terms as $key => $term ) {
  260.         if ( ! in_array( $term->term_id, $hide_category ) ) {
  261.             $new_terms[] = $term;
  262.         }
  263.         }
  264.         $terms = $new_terms;
  265.     }
  266.   return $terms;
  267. }
  268. add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
  269.  
  270. // Remove Jetpack related products from WooCommerce (https://jetpack.com/support/related-posts/customize-related-posts/)
  271. function exclude_jetpack_related_from_products( $options ) {
  272.     if ( is_product() ) {
  273.         $options['enabled'] = false;
  274.     }
  275.  
  276.     return $options;
  277. }
  278.  
  279. add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_products' );
  280.  
  281. // Only display store notice on pages related to the store (http://www.strangebrewdesign.com/how-to-conditionally-display-the-woocommerce-store-notice/)
  282. function my_hide_notice() {
  283.   if( function_exists('is_woocommerce') ) {
  284.     remove_action( 'wp_footer', 'woocommerce_demo_store' );
  285.     if( is_woocommerce() || is_cart() || is_checkout() ) {
  286.       add_action( 'wp_footer', 'woocommerce_demo_store' );
  287.     }
  288.   }
  289. }
  290. add_action( 'wp', 'my_hide_notice' );
  291.  
  292. // Move additional information out of tabs section (https://stackoverflow.com/questions/19620974/woocommerce-move-product-description-out-tabs-into-summary)
  293. //function woocommerce_template_product_description() {
  294. //wc_get_template( 'single-product/tabs/additional-information.php' );
  295. //}
  296. //add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 30 );
  297.  
  298. add_filter( 'option_active_plugins', 'disable_logged_in_plugin' );
  299.  
  300. function disable_logged_in_plugin( $plugins ) {
  301.  
  302.     // The 'option_active_plugins' hook occurs before any user information get generated,
  303.     // so we need to require this file early to be able to check for logged in status
  304.     require (ABSPATH . WPINC . '/pluggable.php');
  305.  
  306.     if ( current_user_can('administrator') ) {
  307.  
  308.         // Use the plugin folder and main file name here.
  309.         // is used here as an example
  310.            $plugins_not_needed = array ( 'no-right-click-images-plugin/no-right-click-images-plugin.php' );
  311.             foreach ( $plugins_not_needed as $plugin ) {
  312.                 $key = array_search( $plugin, $plugins );
  313.                 if ( false !== $key ) {
  314.                     unset( $plugins[ $key ] );
  315.                 }
  316.             }
  317.         }
  318.  
  319.         return $plugins;
  320.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement