Skip to content

Instantly share code, notes, and snippets.

@andy-kliman
andy-kliman / Sticky Footer.txt
Last active May 31, 2019 09:51
Sticky Footer
<?php if ( have_posts() ) : query_posts('p=1');
while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; endif; wp_reset_query(); ?>
@andy-kliman
andy-kliman / customizer-controls-40
Created July 1, 2017 20:15 — forked from devinsays/customizer-controls-40
WordPress 4.0 Customizer Controls
function prefix_customizer_register( $wp_customize ) {
$wp_customize->add_panel( 'panel_id', array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Example Panel', 'textdomain' ),
'description' => __( 'Description of what this panel does.', 'textdomain' ),
) );
@andy-kliman
andy-kliman / site-title-smilies.php
Created July 1, 2017 15:22 — forked from westonruter/site-title-smilies.php
Selective refresh example plugin
<?php
/**
* Plugin name: Site Title (and Tagline) Smilies
* Description: Demonstration of selective refresh in the Customizer. Selectors are targeting elements in Twenty Fifteen.
* Author: Weston Ruter, XWP
* Plugin URL: https://gist.github.com/westonruter/a15b99bdd07e6f4aae7a
*
* @package SiteTitleSmilies
*/
@andy-kliman
andy-kliman / untitled
Created June 30, 2017 18:36
Edit Shortcuts в кастомайзере
add_action('customize_register', 'dco_customize_register');
function dco_customize_register($wp_customize) {
//FOOTER
$wp_customize->add_section('footer', array(
'title' => 'Подвал',
'priority' => 1,
));
//footer text
@andy-kliman
andy-kliman / customizer-contacts.php
Created June 30, 2017 18:35
Edit Shortcuts в Customizer Wordpress
$wp_customize->selective_refresh->add_partial($setting_1, array(
'selector' => '.contacts',
'render_callback' => function() use ($setting_1) {
return nl2br(get_theme_mod($setting_1));
}
));
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Извините, ничего не найдено.</p>
<?php endif; ?>
@andy-kliman
andy-kliman / customizer.php
Last active June 30, 2017 16:50
Wordpress customizer
<?php
// Добавить новую секцию
$wp_customize->add_section('themeName_sectionName',
array(
'title' => 'Название секции',
'priority' => 120,
)
);
Создать настройку
$wp_customize->add_setting('themeName_settingName');
@andy-kliman
andy-kliman / customizer.php
Created June 30, 2017 15:09
Customizer WordPress
<?php
// Нужно добавить в functions.php -> require get_template_directory() . '/inc/customizer.php';
// Функция, регистрирующая новые panel, sections и setting в Customizer
function yoursitename_new_customizer_settings($wp_customize) {
// Создать настройку логотипа
$wp_customize->add_setting('yoursitename_logo');
// Добавить настройку логотипа в секцию "свойства сайта"
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'yoursitename_logo',
@andy-kliman
andy-kliman / README.md
Created June 30, 2017 14:43 — forked from nielslange/README.md
WordPress snippets

WordPress snippets

Security snippets

Improve WordPress security (.htaccess)

# Enable .htpasswd authentication
<If "%{HTTP_HOST} != 'dev'">
AuthType Basic
AuthName "Login to dashboard"