Last active
September 23, 2016 22:04
-
-
Save sxidsvit/2be2479cb19190620055 to your computer and use it in GitHub Desktop.
Фрагменты кода Pinegrow: полезные снипеты кода на PHP для WP
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
| // Фрагменты кода Pinegrow + полезные фрагменты из других источников | |
| /* functions.php - Pinegrow generated Enqueue Scripts and Styles */ | |
| if ( ! function_exists( 'prokopskiy_2_enqueue_scripts' ) ) : | |
| function prokopskiy_2_enqueue_scripts() { | |
| /* Pinegrow generated Enqueue Scripts Begin */ | |
| wp_deregister_script( 'jquery' ); | |
| wp_enqueue_script( 'jquery', get_template_directory_uri() . '/libs/jquery/jquery-2.1.3.min.js', false, null, true); | |
| wp_deregister_script( 'parallax' ); | |
| wp_enqueue_script( 'parallax', get_template_directory_uri() . '/libs/parallax/parallax.min.js', false, null, true); | |
| wp_deregister_script( 'jquerymagnificpopup' ); | |
| wp_enqueue_script( 'jquerymagnificpopup', get_template_directory_uri() . '/libs/magnific-popup/jquery.magnific-popup.min.js', false, null, true); | |
| wp_deregister_script( 'mixitup' ); | |
| wp_enqueue_script( 'mixitup', get_template_directory_uri() . '/libs/mixitup/mixitup.min.js', false, null, true); | |
| wp_deregister_script( 'pagescrollid' ); | |
| wp_enqueue_script( 'pagescrollid', get_template_directory_uri() . '/libs/scroll2id/PageScroll2id.min.js', false, null, true); | |
| wp_deregister_script( 'waypoints' ); | |
| wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/libs/waypoints/waypoints.min.js', false, null, true); | |
| wp_deregister_script( 'animatecss' ); | |
| wp_enqueue_script( 'animatecss', get_template_directory_uri() . '/libs/animate/animate-css.js', false, null, true); | |
| wp_deregister_script( 'jqbootstrapvalidation' ); | |
| wp_enqueue_script( 'jqbootstrapvalidation', get_template_directory_uri() . '/libs/jqBootstrapValidation/jqBootstrapValidation.js', false, null, true); | |
| wp_deregister_script( 'common' ); | |
| wp_enqueue_script( 'common', get_template_directory_uri() . '/js/common.js', false, null, true); | |
| /* Pinegrow generated Enqueue Scripts End */ | |
| /* Pinegrow generated Enqueue Styles Begin */ | |
| wp_deregister_style( 'bootstrapgrid' ); | |
| wp_enqueue_style( 'bootstrapgrid', get_template_directory_uri() . '/libs/bootstrap/bootstrap-grid.min.css', false, null, 'all'); | |
| wp_deregister_style( 'fontawesome' ); | |
| wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/libs/font-awesome/css/font-awesome.min.css', false, null, 'all'); | |
| wp_deregister_style( 'styles' ); | |
| wp_enqueue_style( 'styles', get_template_directory_uri() . '/libs/linea/styles.css', false, null, 'all'); | |
| wp_deregister_style( 'magnificpopup' ); | |
| wp_enqueue_style( 'magnificpopup', get_template_directory_uri() . '/libs/magnific-popup/magnific-popup.css', false, null, 'all'); | |
| wp_deregister_style( 'animate' ); | |
| wp_enqueue_style( 'animate', get_template_directory_uri() . '/libs/animate/animate.min.css', false, null, 'all'); | |
| wp_deregister_style( 'fonts' ); | |
| wp_enqueue_style( 'fonts', get_template_directory_uri() . '/css/fonts.css', false, null, 'all'); | |
| wp_deregister_style( 'main' ); | |
| wp_enqueue_style( 'main', get_template_directory_uri() . '/css/main.css', false, null, 'all'); | |
| wp_deregister_style( 'purple' ); | |
| wp_enqueue_style( 'purple', get_template_directory_uri() . '/css/skins/purple.css', false, null, 'all'); | |
| wp_deregister_style( 'media' ); | |
| wp_enqueue_style( 'media', get_template_directory_uri() . '/css/media.css', false, null, 'all'); | |
| /* Pinegrow generated Enqueue Styles End */ | |
| } | |
| add_action( 'wp_enqueue_scripts', 'prokopskiy_2_enqueue_scripts' ); | |
| endif; | |
| /* end functions.php | |
| // Используем Theme Оptions и выводим посты | |
| <div class="row"> | |
| <?php | |
| $blocks_args = array( | |
| 'post_parent' => get_theme_mod('blocks_content_1_9_source'), | |
| 'post_type' => 'blocks_content', | |
| 'post_status' => 'publish', | |
| 'nopaging' => true, | |
| 'order' => 'ASC', | |
| 'orderby' => 'menu_order' | |
| ) | |
| ?> | |
| <?php $blocks = new WP_Query( $blocks_args ); ?> | |
| <?php if ( $blocks->have_posts() ) : ?> | |
| <?php $blocks_item_number = 0; ?> | |
| <?php while ( $blocks->have_posts() ) : $blocks->the_post(); ?> | |
| <div class="col-md-4 col-sm-12 col-xs-12 pad25"> | |
| <div class="col-xs-2"> | |
| <span class="fa <?php echo get_post_meta( get_the_ID(), 'icon', true ); ?>"></span> | |
| </div> | |
| <div class="col-xs-10"> | |
| <h4><?php the_title(); ?></h4> | |
| <?php the_content(); ?> | |
| </div> | |
| </div> | |
| <?php $blocks_item_number++; ?> | |
| <?php if( $blocks_item_number % 3 == 0 ) echo '<div class="clearfix visible-md-block visible-lg-block"></div>'; ?> | |
| <?php if( $blocks_item_number % 1 == 0 ) echo '<div class="clearfix visible-sm-block"></div>'; ?> | |
| <?php if( $blocks_item_number % 1 == 0 ) echo '<div class="clearfix visible-xs-block"></div>'; ?> | |
| <?php endwhile; ?> | |
| <?php wp_reset_postdata(); ?> | |
| <?php else : ?> | |
| <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> | |
| <?php endif; ?> | |
| </div> | |
| -------------------------------------------------------------------------------------------------------------------------------- | |
| <!-- Register Sidebars --> | |
| <?php if ( is_active_sidebar( 'blocks_promo1_sidebar' ) ) : ?> | |
| <?php dynamic_sidebar( 'blocks_promo1_sidebar' ); ?> | |
| <?php endif; ?> | |
| <!-- Functions.php section Register Sidebars --> | |
| register_sidebar( array( | |
| 'name' => __( 'Promo 1 Sidebar', 'blockdemo' ), | |
| 'id' => 'blocks_promo1_sidebar', | |
| 'before_widget' => '<div>', | |
| 'after_widget' => '</div>', | |
| 'before_title' => '<h3 class="widgettitle">', | |
| 'after_title' => '</h3>' | |
| ) ); | |
| -------------------------------------------------------------------------------------------------------------------------------- | |
| <!-- Формируем WP_Query запрос (аргументы запроса), поучаем его результат и используем в выводе --> | |
| <div class="row"> | |
| <?php | |
| $clients_args = array( | |
| 'post_parent' => get_theme_mod('blocks_content_1_7_source'), | |
| 'post_type' => 'blocks_content', | |
| 'post_status' => 'publish', | |
| 'nopaging' => true, | |
| 'order' => 'ASC', | |
| 'orderby' => 'menu_order' | |
| ) | |
| ?> | |
| <?php $clients = new WP_Query( $clients_args ); ?> | |
| <?php if ( $clients->have_posts() ) : ?> | |
| <?php while ( $clients->have_posts() ) : $clients->the_post(); ?> | |
| <div class="col-md-2 col-sm-4"> | |
| <?php the_post_thumbnail( 'medium', array( | |
| 'alt' => __( 'Client', 'blockdemo' ) | |
| ) ); ?> | |
| </div> | |
| <?php endwhile; ?> | |
| <?php wp_reset_postdata(); ?> | |
| <?php endif; ?> | |
| </div> | |
| -------------------------------------------------------------------------------------------------------------------------------- | |
| <!-- Используем произвольные поля для вывода социальных иконок --> | |
| <ul class="social social-dark"> | |
| <?php if ( get_post_meta( get_the_ID(), 'social_facebook', true ) ) : ?> | |
| <li> | |
| <a href="<?php echo get_post_meta( get_the_ID(), 'social_facebook', true ); ?>"><i class="fa fa-2x fa-facebook"></i></a> | |
| </li> | |
| <?php endif; ?> | |
| <?php if ( get_post_meta( get_the_ID(), 'social_twitter', true ) ) : ?> | |
| <li> | |
| <a href="<?php echo get_post_meta( get_the_ID(), 'social_twitter', true ); ?>"><i class="fa fa-2x fa-twitter"></i></a> | |
| </li> | |
| <?php endif; ?> | |
| <?php if ( get_post_meta( get_the_ID(), 'social_google', true ) ) : ?> | |
| <li> | |
| <a href="<?php echo get_post_meta( get_the_ID(), 'social_google', true ); ?>"><i class="fa fa-2x fa-google-plus"></i></a> | |
| </li> | |
| <?php endif; ?> | |
| <?php if ( get_post_meta( get_the_ID(), 'social_pinterest', true ) ) : ?> | |
| <li> | |
| <a href="<?php echo get_post_meta( get_the_ID(), 'social_pinterest', true ); ?>"><i class="fa fa-2x fa-pinterest"></i></a> | |
| </li> | |
| <?php endif; ?> | |
| <?php if ( get_post_meta( get_the_ID(), 'social_behance', true ) ) : ?> | |
| <li> | |
| <a href="<?php echo get_post_meta( get_the_ID(), 'social_behance', true ); ?>"><i class="fa fa-2x fa-behance"></i></a> | |
| </li> | |
| <?php endif; ?> | |
| <?php if ( get_post_meta( get_the_ID(), 'social_dribbble', true ) ) : ?> | |
| <li> | |
| <a href="<?php echo get_post_meta( get_the_ID(), 'social_dribbble', true ); ?>"><i class="fa fa-2x fa-dribbble"></i></a> | |
| </li> | |
| <?php endif; ?> | |
| </ul> | |
| -------------------------------------------------------------------------------------------------------------------------------- | |
| <!-- Удаляем лишнее с head части сайта --> | |
| <?php | |
| remove_action( 'wp_head', 'feed_links_extra', 3 ); | |
| remove_action( 'wp_head', 'feed_links', 2 ); | |
| remove_action( 'wp_head', 'rsd_link' ); | |
| remove_action( 'wp_head', 'wlwmanifest_link' ); | |
| remove_action( 'wp_head', 'index_rel_link' ); | |
| remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); | |
| remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); | |
| #remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Убираем связанные ссылки //3.0+ | |
| remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); // Ссылки на соседние статьи (<link rel='next'... <link rel='prev'...) | |
| remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); // Короткая ссылка, ссылка без ЧПУ <link rel='shortlink' | |
| //add_filter('template_redirect', function(){ if( is_page() ) remove_action( "wp_head", "rel_canonical" ); }); // удаляем rel_canonical для страниц | |
| add_filter('the_generator', '__return_empty_string'); // Убираем версию WordPress | |
| ?> | |
| <?php | |
| /* My Customizer Controls for custom choise of theme color === Begin */ | |
| /* | |
| <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/skins/<?php echo get_theme_mod('site_color_theme', __( 'blue', 'prokopskiy_2' )); ?>.css" /> | |
| */ | |
| $wp_customize->add_setting('site_color_theme', array( | |
| 'default' => 'blue', | |
| 'capability' => 'edit_theme_options', | |
| 'type' => 'theme_mod' | |
| // 'type' => 'option', | |
| )); | |
| $wp_customize->add_control( 'site_color_theme', array( | |
| // 'settings' => 'site_color_theme', | |
| 'label' => 'Выбирите цветовую схему:', | |
| 'section' => 'contacts_section', | |
| 'type' => 'select', | |
| 'choices' => array( | |
| 'pink' => 'pink', // 'value1' => 'Choice 1' | |
| 'blue' => 'blue', | |
| 'tomato' => 'tomato', | |
| 'purple' => 'purple', | |
| ), | |
| )); | |
| /* My Customizer Controls for custom choise of theme color === End */ | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment