Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / frontpage_sticky_posts.php
Created December 4, 2019 21:55
Show sticky posts on the front page
/**
* Show sticky posts on the front page
*
* @link - https://wordpress.stackexchange.com/questions/202896/query-only-sticky-posts
*/
function edward_frontpage_sticky_posts() {
$stickies = get_option( 'sticky_posts' );
$features = new WP_Query(
array(
@designbuildtest
designbuildtest / featured_content_list.php
Created December 4, 2019 21:53
Show featured posts on the front page
$args = array(
'show_option_all' => __( 'Select a category', 'inmyarea' ),
//'show_option_none' => '',
//'option_none_value' => '-1',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'selected' => $cat,
'hierarchical' => 1,
'name' => 'browse',
@designbuildtest
designbuildtest / sanitize-checkbox.php
Created September 30, 2015 04:05
Sanitize checkbox
<?php
// Sanitize Checkbox.
function dbt_sanitize_checkbox( $value ) {
if ( 1 == $value ) {
return true;
}
else {
return false;
}
}
@designbuildtest
designbuildtest / yes-no-choices.php
Created September 30, 2015 04:02
Customizer YES/NO choices
<?php
// Sanitize YES/NO choice.
function dbt_yes_no_choices() {
return apply_filters( 'dbt_yes_no_choices', array(
'no' => __( 'No' ),
'yes' => __( 'Yes' ),
) );
}
function dbt_sanitize_yes_no_choice( $value ) {
@designbuildtest
designbuildtest / language-customizer-control.php
Last active September 30, 2015 03:57
Language customizer control
<?php
/**
* Language
*
*/
$wp_customize->add_setting( 'WPLANG', array(
'type' => 'option',
'sanitize_callback' => 'dbt_sanitize_language_choice',
) );
$wp_customize->add_control( 'WPLANG', array(
@designbuildtest
designbuildtest / timezone.php
Created September 30, 2015 03:54
Timezone customizer setting and control
<?php
/**
* Timezone
*
*/
$wp_customize->add_setting( 'timezone_string', array(
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
) );
class Timezone_Control extends WP_Customize_Control {
@designbuildtest
designbuildtest / misc-settings.php
Created September 30, 2015 03:53
Miscellaneous settings
<?php
/**
* Miscellaneous
*
*/
$advanced_count = 10;
$advanced_array = array(
__( 'Google Analytics Tracking Code' ) => 'dbt_google_analytics_code',
//__( 'Facebook Comments App ID' ) => 'dbt_facebook_comments_app_id',
@designbuildtest
designbuildtest / google-analytics.php
Created September 30, 2015 03:49
Google Analytics tracking code HTML
<?php
/**
* Google Analytics tracking code.
*/
function dbt_add_google_analytics_tracking_code_to_document_head() {
$google_analytics_code = get_option( 'dbt_google_analytics_code' );
if ( $google_analytics_code && ! is_user_logged_in() && ! is_customize_preview() ) { ?>
<!-- Google Analytics -->
@designbuildtest
designbuildtest / facebook-disqus.php
Created September 29, 2015 21:27
Facebook and Disqus Comments
/**
* Facebook and Disqus Comments - drop-in replacement for comments.php
*/
function dbt_facebook_or_disqus_comments() {
if ( comments_open() && get_option( 'dbt_facebook_comments_app_id' ) ) {
// If Facebook Comments enabled.
if ( get_option( 'WPLANG' ) ) { $language = get_option( 'WPLANG' ); }
else { $language = 'en_US'; } ?>
<div id="fb-root"></div>