Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Add your custom modifications here, this file will never be modified by an update.
- *
- * This file is included at the end of functions.php file.
- *
- * @since fluxus 1.0
- */
- /**
- * Reorder Style Sheets in WordPress
- * https://blog.calevans.com/2015/03/04/reordering-style-sheets-in-wordpress/
- */
- function cal_adjuststylesheets() {
- global $wp_styles;
- $keys=[];
- $keys[] = 'responsive-lightbox-prettyphoto';
- $keys[] = 'photoswipe'; // WooCommerce
- $keys[] = 'photoswipe-default-skin'; // WooCommerce
- $keys[] = 'select2'; // WooCommerce
- $keys[] = 'woocommerce-inline-inline';
- $keys[] = 'woocommerce-general';
- $keys[] = 'woocommerce-smallscreen';
- $keys[] = 'woocommerce-layout';
- $keys[] = 'woocommerce-layout-inline';
- $keys[] = 'wpdreams-asl-basic';
- $keys[] = 'wpdreams-ajaxsearchlite';
- $keys[] = 'social-logos';
- $keys[] = 'jetpack_css';
- $keys[] = 'fluxus-normalize';
- $keys[] = 'fluxus-global';
- $keys[] = 'fluxus-icons';
- $keys[] = 'fluxus-style';
- $keys[] = 'fluxus-grid';
- $keys[] = 'fontello-icons';
- $keys[] = 'fluxus-style';
- $keys[] = 'fluxus-skin';
- $keys[] = 'fluxus-responsive';
- $keys[] = 'fluxus-customizer';
- $keys[] = 'fluxus-user';
- foreach($keys as $currentKey) {
- $keyToSplice = array_search($currentKey,$wp_styles->queue);
- if ($keyToSplice!==false && !is_null($keyToSplice)) {
- $elementToMove = array_splice($wp_styles->queue,$keyToSplice,1);
- $wp_styles->queue[] = $elementToMove[0];
- }
- }
- return;
- }
- add_action( 'wp_print_styles', 'cal_adjuststylesheets', 99 );
- /**
- * Disable Fluxus gallery
- * https://themeforest.net/item/fluxus-portfolio-theme-for-photographers/3854385
- */
- remove_filter( 'post_gallery', 'fluxus_shortcode_gallery', 2 );
- /**
- * Move Jetpack Sharing Buttons
- * https://jetpack.com/2013/06/10/moving-sharing-icons/
- */
- function jptweak_remove_share() {
- remove_filter( 'the_content', 'sharing_display', 19 );
- remove_filter( 'the_excerpt', 'sharing_display', 19 );
- if ( class_exists( 'Jetpack_Likes' ) ) {
- remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
- }
- }
- add_action( 'loop_start', 'jptweak_remove_share' );
- /**
- * Jetpack: add theme support for Responsive Videos.
- * https://jetpack.com/support/responsive-videos/
- */
- function jetpackme_responsive_videos_setup() {
- add_theme_support( 'jetpack-responsive-videos' );
- }
- add_action( 'after_setup_theme', 'jetpackme_responsive_videos_setup' );
- /**
- * Jetpack: remove Jetpack Related Posts on fluxus portfolio post type
- * https://wpteardown.com/remove-jetpacks-related-post-custom-post-types-cpt/
- */
- function afn_jetpack_singular_no_related_posts( $options ) {
- if ( is_singular( 'fluxus_portfolio' ) ) {
- $options['enabled'] = false;
- }
- return $options;
- }
- add_filter( 'jetpack_relatedposts_filter_options', 'afn_jetpack_singular_no_related_posts' );
- /**
- * Modificaciones a WooCommerce
- * https://docs.woocommerce.com/
- */
- // Adds WooCommerce theme support (https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/)
- remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
- remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
- add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
- add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
- function my_theme_wrapper_start() {
- echo '<div id="main" class="site site-with-sidebar">';
- echo '<div id="content" class="site-content">';
- if(function_exists('bcn_display')) {
- echo '<div class="bread-woo">';
- bcn_display();
- echo '</div>';
- }
- }
- function my_theme_wrapper_end() {
- echo '</div>';
- get_sidebar();
- echo '</div>';
- }
- add_action( 'after_setup_theme', 'woocommerce_support' );
- function woocommerce_support() {
- add_theme_support( 'woocommerce' );
- }
- // Compatibilidad con galerías de WordPress a partir de WooCommerce 3.0>
- add_action( 'after_setup_theme', 'yourtheme_setup' );
- function yourtheme_setup() {
- add_theme_support( 'wc-product-gallery-zoom' );
- add_theme_support( 'wc-product-gallery-lightbox' );
- add_theme_support( 'wc-product-gallery-slider' );
- }
- // Remove WooCommerce breadcrumb (https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/#section-4)
- add_action( 'init', 'jk_remove_wc_breadcrumbs' );
- function jk_remove_wc_breadcrumbs() {
- remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
- }
- // 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)
- add_action( 'init', 'add_filter_change_existing_currency_symbol', PHP_INT_MAX );
- function add_filter_change_existing_currency_symbol() {
- add_filter( 'woocommerce_currency_symbol', 'change_existing_currency_symbol', PHP_INT_MAX, 2 );
- }
- function change_existing_currency_symbol( $currency_symbol, $currency ) {
- switch( $currency ) {
- case 'ARS': $currency_symbol = 'ARS ';
- break;
- case 'USD': $currency_symbol = 'US$ ';
- break;
- }
- return $currency_symbol;
- }
- // Remove the sorting dropdown from Woocommerce Categories (https://hirejordansmith.com/how-to-remove-the-woocommerce-results-count/)
- remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_catalog_ordering', 30 );
- // Remove the result count from WooCommerce Categories
- remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_result_count', 20 );
- // Remove "Add to Cart" Buttons on WooCommerce Shop Archives Page and Categories page (https://isabelcastillo.com/remove-add-to-cart-buttons-woocommerce)
- remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
- // Remove page title from WooCommerce Shop and Categories pages (https://gist.github.com/corsonr/8703820)
- add_filter( 'woocommerce_show_page_title' , 'woo_hide_page_title' );
- function woo_hide_page_title() {
- return false;
- }
- // Removes products count after Categories name (http://www.remicorson.com/woocommerce-remove-category-products-count/)
- add_filter( 'woocommerce_subcategory_count_html', 'woo_remove_category_products_count' );
- function woo_remove_category_products_count() {
- return;
- }
- // Display 9 products per page (https://docs.woocommerce.com/document/change-number-of-products-displayed-per-page/)
- add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 9;' ), 20 );
- // Change number of related products output (https://docs.woocommerce.com/document/change-number-of-related-products-output/)
- function woo_related_products_limit() {
- global $product;
- $args['posts_per_page'] = 6;
- return $args;
- }
- add_filter( 'woocommerce_output_related_products_args', 'jk_related_products_args' );
- function jk_related_products_args( $args ) {
- $args['posts_per_page'] = 3; // 3 related products
- $args['columns'] = 3; // arranged in 3 columns
- return $args;
- }
- // Remove images in single product page (https://www.skyverge.com/blog/hide-woocommerce-product-image/)
- remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
- // Change labels for Direct bank transfer payment method (https://wordpress.stackexchange.com/questions/77783/change-label-for-field-used-in-woo-commerce/77836#77836)
- function woocommerce_bacs_account_fields($translation, $text, $domain) {
- if ($domain == 'woocommerce') {
- switch ($text) {
- case 'Sort code':
- $translation = 'Alias';
- break;
- case 'IBAN':
- $translation = 'CBU';
- break;
- case 'BIC':
- $translation = 'CUIT';
- break;
- }
- }
- return $translation;
- }
- add_filter('gettext', 'woocommerce_bacs_account_fields', 10, 3);
- // 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)
- function custom_single_product_image_html( $html, $post_id ) {
- $post_thumbnail_id = get_post_thumbnail_id( $post_id );
- return get_the_post_thumbnail( $post_thumbnail_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
- }
- add_filter('woocommerce_single_product_image_thumbnail_html', 'custom_single_product_image_html', 10, 2);
- // Mueve las tabs hacia arriba de los botones de Jetpack Sharing (https://www.dariobf.com/cambiar-orden-elementos-producto-woocommerce/)
- remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
- add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 30 );
- // Mueve productos relacionados arriba de etiquetas
- remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
- add_action( 'woocommerce_single_product_summary', 'woocommerce_output_related_products', 30 );
- // Remove password strength check (https://iconicwp.com/blog/disable-password-strength-meter-woocommerce/)
- function iconic_remove_password_strength() {
- wp_dequeue_script( 'wc-password-strength-meter' );
- }
- add_action( 'wp_print_scripts', 'iconic_remove_password_strength', 10 );
- // Pone el resumen arriba del título
- remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
- add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 0 );
- // Hide categories by ID (https://www.tychesoftwares.com/hide-woocommerce-categories-shop/)
- function get_subcategory_terms( $terms, $taxonomies, $args ) {
- $new_terms = array();
- $hide_category = array( 281 ); // Ids of the category you don't want to display on the shop page
- // if a product category and on the shop page
- if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
- foreach ( $terms as $key => $term ) {
- if ( ! in_array( $term->term_id, $hide_category ) ) {
- $new_terms[] = $term;
- }
- }
- $terms = $new_terms;
- }
- return $terms;
- }
- add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
- // Remove Jetpack related products from WooCommerce (https://jetpack.com/support/related-posts/customize-related-posts/)
- function exclude_jetpack_related_from_products( $options ) {
- if ( is_product() ) {
- $options['enabled'] = false;
- }
- return $options;
- }
- add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_products' );
- // Only display store notice on pages related to the store (http://www.strangebrewdesign.com/how-to-conditionally-display-the-woocommerce-store-notice/)
- function my_hide_notice() {
- if( function_exists('is_woocommerce') ) {
- remove_action( 'wp_footer', 'woocommerce_demo_store' );
- if( is_woocommerce() || is_cart() || is_checkout() ) {
- add_action( 'wp_footer', 'woocommerce_demo_store' );
- }
- }
- }
- add_action( 'wp', 'my_hide_notice' );
- // Move additional information out of tabs section (https://stackoverflow.com/questions/19620974/woocommerce-move-product-description-out-tabs-into-summary)
- //function woocommerce_template_product_description() {
- //wc_get_template( 'single-product/tabs/additional-information.php' );
- //}
- //add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 30 );
- add_filter( 'option_active_plugins', 'disable_logged_in_plugin' );
- function disable_logged_in_plugin( $plugins ) {
- // The 'option_active_plugins' hook occurs before any user information get generated,
- // so we need to require this file early to be able to check for logged in status
- require (ABSPATH . WPINC . '/pluggable.php');
- if ( current_user_can('administrator') ) {
- // Use the plugin folder and main file name here.
- // is used here as an example
- $plugins_not_needed = array ( 'no-right-click-images-plugin/no-right-click-images-plugin.php' );
- foreach ( $plugins_not_needed as $plugin ) {
- $key = array_search( $plugin, $plugins );
- if ( false !== $key ) {
- unset( $plugins[ $key ] );
- }
- }
- }
- return $plugins;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement