Last active
April 9, 2019 17:49
-
-
Save eto4detak/32bd9b2dc70aa71aee598e002767b632 to your computer and use it in GitHub Desktop.
wp php filter states-page
This file contains hidden or 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 | |
/*======================================================== | |
* фильтровать вывод в главном цикле | |
========================================================*/ | |
function devise_number_displayed_posts($query) { | |
if (is_admin() || !$query->is_main_query()) { | |
return; | |
} | |
if (is_tax('category-catalogs')) { | |
$query->set('posts_per_page', 16); | |
return; | |
} | |
if (is_tax('product_cat')) { | |
$screen_width = isset($_COOKIE['screen_width']) ? $_COOKIE['screen_width'] : ''; | |
if($screen_width){ | |
$count_in_row = art_get_data_layout($screen_width); | |
$count_in_row = $count_in_row >= 1 ? $count_in_row: ''; | |
if(!empty($count_in_row)){ | |
$query->set('posts_per_page', $count_in_row); | |
return; | |
} | |
} | |
} | |
} | |
add_action('pre_get_posts', 'devise_number_displayed_posts', 1); | |
/*======================================================== | |
* states | |
========================================================*/ | |
add_filter( 'display_post_states', 'pixad_add_display_post_states', 15, 2 ); | |
function pixad_add_display_post_states( $post_states, $post ) { | |
$Settings = new PIXAD_Settings(); | |
$options = $Settings->getSettings( 'WP_OPTIONS', '_pixad_autos_settings', true ); | |
$auto_sell_page = isset($options['autos_sell_car_page']) ? $options['autos_sell_car_page'] : false; | |
$auto_listing_page = isset($options['autos_listing_car_page']) ? $options['autos_listing_car_page'] : false; | |
$auto_update_page = isset($options['autos_update_car_page']) ? $options['autos_update_car_page'] : false; | |
$auto_my_page = isset($options['autos_my_cars_page']) ? $options['autos_my_cars_page'] : false; | |
if ($post->ID == $auto_sell_page){ | |
$post_states['wc_page_for_shop'] = __( 'Sell Your Car Page', 'pixautodeal' ); | |
}elseif($post->ID == $auto_listing_page){ | |
$post_states['wc_page_for_shop'] = __( 'Listing Car Page', 'pixautodeal' ); | |
}elseif($post->ID == $auto_update_page){ | |
$post_states['wc_page_for_shop'] = __( 'Car Update Page', 'pixautodeal' ); | |
}elseif($post->ID == $auto_my_page){ | |
$post_states['wc_page_for_shop'] = __( 'My Cars Page', 'pixautodeal' ); | |
} | |
return $post_states; | |
} | |
/*======================================================== | |
* SEO | |
========================================================*/ | |
add_filter( 'pre_get_document_title', 'diviecim_wpseo_title_filter', 9999); | |
add_filter( 'wpseo_opengraph_title', 'diviecim_wpseo_title_filter', 9999); | |
add_filter( 'wpseo_title', 'diviecim_wpseo_title_filter', 9999); | |
function diviecim_wpseo_title_filter($title){ | |
global $post, $product; | |
if(is_product() && is_single()){ | |
$text = ''; | |
$term_parent = get_the_terms($post->ID, 'product_cat' )[0]; | |
return $text; | |
} | |
return $title; | |
} | |
add_filter( 'wpseo_metadesc', 'diviecim_wpseo_metadesc_filter' , 99); | |
//фильтр описания страницы | |
function diviecim_wpseo_metadesc_filter($html='') | |
{ | |
return $html; | |
} | |
/*======================================================== | |
* customize | |
========================================================*/ | |
add_action( 'admin_notices', 'admin_activation_notice__error' ); | |
add_action( 'customize_register', 'pixtheme_customize_register'); | |
add_action( 'login_head', 'pixtheme_admin_logo_scripts'); | |
function pixtheme_admin_logo_scripts(){ | |
$licenceStatus = '<script>var pixthemeLicence = "' . (( pixtheme_check_is_activated() != false ) ? 'Yes' : 'No') . '"; </script>' ; | |
echo $licenceStatus; | |
} | |
function pixtheme_customize_register($wp_customize ) { | |
$wp_customize->add_section( 'pixtheme_licence_settings' , array( | |
'title' => esc_html__( 'Theme Activation', 'pixtheme-custom' ), | |
'priority' => 1, | |
) ); | |
$wp_customize->add_setting( 'pixtheme_licence_settings_code' , array( | |
'transport' => 'refresh', | |
'sanitize_callback' => 'sanitize_text_field' | |
) ); | |
$wp_customize->add_control( | |
'pixtheme_licence_settings_code', | |
array( | |
'label' => esc_html__( 'Envato Licence Code', 'pixtheme-custom' ), | |
'section' => 'pixtheme_licence_settings', | |
'settings' => 'pixtheme_licence_settings_code', | |
'description' => 'You are licensed to use the Item to create one single End Product for yourself or for one client . If you want to create more sites please purchase a new license or buy Extended License if you do not purchased this product please urgently contact us to obtain a license <a href="mailto:[email protected]"> [email protected] </a>', | |
'type' => 'textfield', | |
'priority' => 10 | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment