did some sniff sniff

This commit is contained in:
2025-07-14 21:47:29 -07:00
parent c6bb1b7c7b
commit 0e9321b01a
44 changed files with 2557 additions and 2259 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
vendor
composer.lock

View File

@@ -33,12 +33,12 @@ $sophia_after_dark_pnf_latest_posts = get_theme_mod( 'sophia_after_dark_enable_p
<div class="page-extra-content sad-404-latest-posts-wrapper"> <div class="page-extra-content sad-404-latest-posts-wrapper">
<?php <?php
$sophia_after_dark_pnf_latest_post_count = get_theme_mod( 'sophia_after_dark_pnf_latest_post_count', 3 ); $sophia_after_dark_pnf_latest_post_count = get_theme_mod( 'sophia_after_dark_pnf_latest_post_count', 3 );
$sophia_after_dark_pnf_args = array( $sophia_after_dark_pnf_args = array(
'post_type' => 'post', 'post_type' => 'post',
'posts_per_page' => absint( $sophia_after_dark_pnf_latest_post_count ), 'posts_per_page' => absint( $sophia_after_dark_pnf_latest_post_count ),
'ignore_sticky_posts' => 1, 'ignore_sticky_posts' => 1,
); );
$sophia_after_dark_pnf_query = new WP_Query( $sophia_after_dark_pnf_args ); $sophia_after_dark_pnf_query = new WP_Query( $sophia_after_dark_pnf_args );
if ( $sophia_after_dark_pnf_query->have_posts() ) : if ( $sophia_after_dark_pnf_query->have_posts() ) :
echo '<div class="sad-pnf-latest-posts-wrapper sad-related-posts-wrapper">'; echo '<div class="sad-pnf-latest-posts-wrapper sad-related-posts-wrapper">';

View File

@@ -44,11 +44,13 @@ get_header();
<?php <?php
// Archive pagination // Archive pagination
the_posts_pagination( array( the_posts_pagination(
'prev_text' => __( 'Previous', 'sophia-after-dark' ), array(
'next_text' => __( 'Next', 'sophia-after-dark' ), 'prev_text' => __( 'Previous', 'sophia-after-dark' ),
'before_page_number' => '<span class="screen-reader-text">' . esc_html__( 'Page', 'sophia-after-dark' ) . ' </span>', 'next_text' => __( 'Next', 'sophia-after-dark' ),
) ); 'before_page_number' => '<span class="screen-reader-text">' . esc_html__( 'Page', 'sophia-after-dark' ) . ' </span>',
)
);
?> ?>
<?php else : ?> <?php else : ?>

View File

@@ -21,16 +21,16 @@ if ( post_password_required() ) {
} }
// Remove URL field from comment form // Remove URL field from comment form
function sophia_after_dark_remove_url_comments($fields) { function sophia_after_dark_remove_url_comments( $fields ) {
unset($fields['url']); unset( $fields['url'] );
return $fields; return $fields;
} }
add_filter('comment_form_default_fields', 'sophia_after_dark_remove_url_comments'); add_filter( 'comment_form_default_fields', 'sophia_after_dark_remove_url_comments' );
// Modify cookie consent field // Modify cookie consent field
function sophia_after_dark_comment_form_change_cookies($fields) { function sophia_after_dark_comment_form_change_cookies( $fields ) {
$commenter = wp_get_current_commenter(); $commenter = wp_get_current_commenter();
$consent = ! empty( $commenter['comment_author_email'] ); $consent = ! empty( $commenter['comment_author_email'] );
$fields['cookies'] = sprintf( $fields['cookies'] = sprintf(
'<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" %s /> <label for="wp-comment-cookies-consent">%s</label></p>', '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" %s /> <label for="wp-comment-cookies-consent">%s</label></p>',
@@ -40,23 +40,23 @@ function sophia_after_dark_comment_form_change_cookies($fields) {
return $fields; return $fields;
} }
add_filter('comment_form_default_fields', 'sophia_after_dark_comment_form_change_cookies'); add_filter( 'comment_form_default_fields', 'sophia_after_dark_comment_form_change_cookies' );
// Add comment notes above form // Add comment notes above form
function sophia_after_dark_modify_text_before_comment_form($arg) { function sophia_after_dark_modify_text_before_comment_form( $arg ) {
$arg['comment_notes_before'] = wp_kses_post( $arg['comment_notes_before'] = wp_kses_post(
'<p class="comment-notes">' . '<p class="comment-notes">' .
esc_html__('All comments are manually reviewed and moderated.', 'sophia-after-dark') . esc_html__( 'All comments are manually reviewed and moderated.', 'sophia-after-dark' ) .
'<br><span class="required-field-message">' . '<br><span class="required-field-message">' .
esc_html__('Required fields are marked ', 'sophia-after-dark') . esc_html__( 'Required fields are marked ', 'sophia-after-dark' ) .
'<span class="required">*</span></span></p>' '<span class="required">*</span></span></p>'
); );
return $arg; return $arg;
} }
add_filter('comment_form_defaults', 'sophia_after_dark_modify_text_before_comment_form'); add_filter( 'comment_form_defaults', 'sophia_after_dark_modify_text_before_comment_form' );
// Add privacy policy consent note below form // Add privacy policy consent note below form
function sophia_after_dark_modify_text_comment_form($post_id) { function sophia_after_dark_modify_text_comment_form( $post_id ) {
$link = '<a href="/privacy-policy">' . esc_html__( 'Privacy Policy', 'sophia-after-dark' ) . '</a>'; $link = '<a href="/privacy-policy">' . esc_html__( 'Privacy Policy', 'sophia-after-dark' ) . '</a>';
printf( printf(
'<span class="submit-comment-note">%s</span>', '<span class="submit-comment-note">%s</span>',
@@ -69,7 +69,7 @@ function sophia_after_dark_modify_text_comment_form($post_id) {
) )
); );
} }
add_action('comment_form', 'sophia_after_dark_modify_text_comment_form'); add_action( 'comment_form', 'sophia_after_dark_modify_text_comment_form' );
?> ?>
@@ -99,11 +99,13 @@ add_action('comment_form', 'sophia_after_dark_modify_text_comment_form');
<ol class="comment-list"> <ol class="comment-list">
<?php <?php
wp_list_comments( array( wp_list_comments(
'style' => 'ol', array(
'short_ping' => true, 'style' => 'ol',
'reply_text' => __( 'Reply', 'sophia-after-dark' ), 'short_ping' => true,
) ); 'reply_text' => __( 'Reply', 'sophia-after-dark' ),
)
);
?> ?>
</ol> </ol>

13
composer.json Normal file
View File

@@ -0,0 +1,13 @@
{
"require-dev": {
"squizlabs/php_codesniffer": "^3.13",
"wp-coding-standards/wpcs": "^3.1",
"phpcsstandards/phpcsutils": "^1.1",
"dealerdirect/phpcodesniffer-composer-installer": "^1.1"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

View File

@@ -11,28 +11,28 @@
*/ */
?> ?>
</div> </div>
</div> </div>
<?php <?php
/** /**
* sophia_after_dark before footer * sophia_after_dark before footer
* *
* @since 1.0.0 * @since 1.0.0
*/ */
do_action( 'sophia_after_dark_before_footer' ); do_action( 'sophia_after_dark_before_footer' );
/** /**
* sophia_after_dark footer * sophia_after_dark footer
* *
* @hooked - sophia_after_dark_footer_start - 5 * @hooked - sophia_after_dark_footer_start - 5
* @hooked - sophia_after_dark_footer_sidebar - 10 * @hooked - sophia_after_dark_footer_sidebar - 10
* @hooked - sophia_after_dark_bottom_footer - 15 * @hooked - sophia_after_dark_bottom_footer - 15
* @hooked - sophia_after_dark_footer_end - 20 * @hooked - sophia_after_dark_footer_end - 20
* *
* @since 1.0.0 * @since 1.0.0
*/ */
do_action( 'sophia_after_dark_footer' ); do_action( 'sophia_after_dark_footer' );
/** /**
@@ -49,13 +49,13 @@
<?php <?php
/** /**
* sophia_after_dark_after_page hook * sophia_after_dark_after_page hook
* *
* @since 1.0.0 * @since 1.0.0
*/ */
do_action( 'sophia_after_dark_after_page' ); do_action( 'sophia_after_dark_after_page' );
wp_footer(); wp_footer();
?> ?>
</body> </body>
</html> </html>

View File

@@ -15,7 +15,7 @@ if ( ! function_exists( 'sophia_after_dark_setup' ) ) :
* runs before the init hook. The init hook is too late for some features, such * runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails. * as indicating support for post thumbnails.
*/ */
function sophia_after_dark_setup(){ function sophia_after_dark_setup() {
/* /*
* Make theme available for translation. * Make theme available for translation.
* Translations can be filed in the /languages/ directory. * Translations can be filed in the /languages/ directory.
@@ -49,30 +49,35 @@ if ( ! function_exists( 'sophia_after_dark_setup' ) ) :
add_image_size( 'sophia-after-dark-slider-post', 1200, 700, true ); add_image_size( 'sophia-after-dark-slider-post', 1200, 700, true );
// This theme uses wp_nav_menu() in one location. // This theme uses wp_nav_menu() in one location.
register_nav_menus( array( register_nav_menus(
'top_header_menu' => esc_html__( 'Top Header', 'sophia-after-dark' ), array(
'primary_menu' => esc_html__( 'Primary', 'sophia-after-dark' ), 'top_header_menu' => esc_html__( 'Top Header', 'sophia-after-dark' ),
'footer_menu' => esc_html__( 'Footer', 'sophia-after-dark' ), 'primary_menu' => esc_html__( 'Primary', 'sophia-after-dark' ),
) ); 'footer_menu' => esc_html__( 'Footer', 'sophia-after-dark' ),
)
);
/* /*
* Switch default core markup for search form, comment form, and comments * Switch default core markup for search form, comment form, and comments
* to output valid HTML5. * to output valid HTML5.
*/ */
add_theme_support( 'html5', array( add_theme_support(
'search-form', 'html5',
'comment-form', array(
'comment-list', 'search-form',
'gallery', 'comment-form',
'caption', 'comment-list',
) ); 'gallery',
'caption',
)
);
// Set up the WordPress core custom background feature. // Set up the WordPress core custom background feature.
// Disabled in V1.4.3 // Disabled in V1.4.3
//add_theme_support( 'custom-background', apply_filters( 'sophia_after_dark_custom_background_args', array( // add_theme_support( 'custom-background', apply_filters( 'sophia_after_dark_custom_background_args', array(
//'default-color' => 'ffffff', // 'default-color' => 'ffffff',
//'default-image' => '', // 'default-image' => '',
//) ) ); // ) ) );
// Add theme support for selective refresh for widgets. // Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'customize-selective-refresh-widgets' );
@@ -82,24 +87,27 @@ if ( ! function_exists( 'sophia_after_dark_setup' ) ) :
* *
* @link https://codex.wordpress.org/Theme_Logo * @link https://codex.wordpress.org/Theme_Logo
*/ */
add_theme_support( 'custom-logo', array( add_theme_support(
'height' => 250, 'custom-logo',
'width' => 250, array(
'flex-width' => true, 'height' => 250,
'flex-height' => true, 'width' => 250,
) ); 'flex-width' => true,
'flex-height' => true,
)
);
/** /**
* Registers an editor stylesheet for the theme. * Registers an editor stylesheet for the theme.
*/ */
add_editor_style( 'assets/css/sad-editor-style.css' ); add_editor_style( 'assets/css/sad-editor-style.css' );
/** /**
* Restoring the classic Widgets Editor * Restoring the classic Widgets Editor
* *
* @since 1.1.5 * @since 1.1.5
*/ */
$sophia_after_dark_enable_widgets_editor = get_theme_mod( 'sophia_after_dark_enable_widgets_editor', false ); $sophia_after_dark_enable_widgets_editor = get_theme_mod( 'sophia_after_dark_enable_widgets_editor', false );
if ( false === $sophia_after_dark_enable_widgets_editor ) { if ( false === $sophia_after_dark_enable_widgets_editor ) {
remove_theme_support( 'widgets-block-editor' ); remove_theme_support( 'widgets-block-editor' );
} }
@@ -128,20 +136,19 @@ add_action( 'after_setup_theme', 'sophia_after_dark_content_width', 0 );
* @global string $sophia_after_dark_theme_version * @global string $sophia_after_dark_theme_version
*/ */
function sophia_after_dark_theme_version_info() { function sophia_after_dark_theme_version_info() {
$sophia_after_dark_theme_info = wp_get_theme(); $sophia_after_dark_theme_info = wp_get_theme();
$GLOBALS['sophia_after_dark_theme_version'] = $sophia_after_dark_theme_info->get( 'Version' ); $GLOBALS['sophia_after_dark_theme_version'] = $sophia_after_dark_theme_info->get( 'Version' );
} }
add_action( 'after_setup_theme', 'sophia_after_dark_theme_version_info', 0 ); add_action( 'after_setup_theme', 'sophia_after_dark_theme_version_info', 0 );
/** /**
* Function for displaying menu item description * Function for displaying menu item description
*
*/ */
function sophia_after_dark_nav_description( $item_output, $item, $depth, $menu_args ) { function sophia_after_dark_nav_description( $item_output, $item, $depth, $menu_args ) {
if ( !empty( $item->description ) ) { if ( ! empty( $item->description ) ) {
$item_output = str_replace( $menu_args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $menu_args->link_after . '</a>', $item_output ); $item_output = str_replace( $menu_args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $menu_args->link_after . '</a>', $item_output );
} }
return $item_output; return $item_output;
} }
add_filter( 'walker_nav_menu_start_el', 'sophia_after_dark_nav_description', 10, 4 ); add_filter( 'walker_nav_menu_start_el', 'sophia_after_dark_nav_description', 10, 4 );
@@ -149,7 +156,7 @@ add_filter( 'walker_nav_menu_start_el', 'sophia_after_dark_nav_description', 10,
* Implement the Custom Header feature. * Implement the Custom Header feature.
* Disabled in V1.4.3 * Disabled in V1.4.3
*/ */
//require get_template_directory() . '/inc/custom-header.php'; // require get_template_directory() . '/inc/custom-header.php';
/** /**
* Custom template tags for this theme. * Custom template tags for this theme.
@@ -201,38 +208,41 @@ if ( ! function_exists( 'breadcrumb_trail' ) ) {
} }
// Function to allow images in WordPress comments // Function to allow images in WordPress comments
function allow_images_in_comments($comment_content) { function allow_images_in_comments( $comment_content ) {
// Allow only specific HTML tags, including <img> // Allow only specific HTML tags, including <img>
$allowed_tags = array( $allowed_tags = array(
'a' => array('href' => array(), 'title' => array()), 'a' => array(
'em' => array(), 'href' => array(),
'strong' => array(), 'title' => array(),
'img' => array( ),
'src' => array(), 'em' => array(),
'alt' => array(), 'strong' => array(),
'width' => array(), 'img' => array(
'height' => array(), 'src' => array(),
'class' => array(), 'alt' => array(),
), 'width' => array(),
); 'height' => array(),
'class' => array(),
),
);
// Strip out disallowed tags but keep allowed ones // Strip out disallowed tags but keep allowed ones
return wp_kses($comment_content, $allowed_tags); return wp_kses( $comment_content, $allowed_tags );
} }
// Hook to filter the comment text before displaying it // Hook to filter the comment text before displaying it
add_filter('comment_text', 'allow_images_in_comments'); add_filter( 'comment_text', 'allow_images_in_comments' );
// Function to make URLs for images clickable in comments // Function to make URLs for images clickable in comments
function clickable_images_in_comments($comment_content) { function clickable_images_in_comments( $comment_content ) {
// Automatically convert image URLs to HTML <img> tags // Automatically convert image URLs to HTML <img> tags
$comment_content = preg_replace( $comment_content = preg_replace(
'/(http:\/\/[^\s"]+\.(jpg|jpeg|png|gif))/i', '/(http:\/\/[^\s"]+\.(jpg|jpeg|png|gif))/i',
'<img src="$1" alt="" class="comment-image" />', '<img src="$1" alt="" class="comment-image" />',
$comment_content $comment_content
); );
return $comment_content; return $comment_content;
} }
// Hook to make image URLs clickable // Hook to make image URLs clickable
add_filter('comment_text', 'clickable_images_in_comments'); add_filter( 'comment_text', 'clickable_images_in_comments' );

View File

@@ -20,35 +20,35 @@
<?php <?php
// Set default author for home page OG metadata // Set default author for home page OG metadata
$author_id = (int) get_option( 'sophia_after_dark_home_og_user', 1 ); $author_id = (int) get_option( 'sophia_after_dark_home_og_user', 1 );
$author_bio = get_the_author_meta( 'description', $author_id ); $author_bio = get_the_author_meta( 'description', $author_id );
if ( is_front_page() ) { if ( is_front_page() ) {
$home_og_image = get_option( 'sophia_after_dark_home_og_image' ); $home_og_image = get_option( 'sophia_after_dark_home_og_image' );
if ( $home_og_image ) { if ( $home_og_image ) {
printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $home_og_image ) ); printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $home_og_image ) );
} }
printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_bloginfo( 'name' ) . ' - ' . get_bloginfo( 'description' ) ) ); printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_bloginfo( 'name' ) . ' - ' . get_bloginfo( 'description' ) ) );
printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( $author_bio ) ); printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( $author_bio ) );
printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( home_url( '/' ) ) ); printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( home_url( '/' ) ) );
} elseif ( is_singular() ) { } elseif ( is_singular() ) {
global $post; global $post;
$thumbnail_url = get_template_directory_uri() . '/assets/images/default-og-image.webp'; $thumbnail_url = get_template_directory_uri() . '/assets/images/default-og-image.webp';
if ( has_post_thumbnail( $post?->ID ) ) { if ( has_post_thumbnail( $post?->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'og-image-size' ); $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'og-image-size' );
if ( ! empty( $image[0] ) ) { if ( ! empty( $image[0] ) ) {
$thumbnail_url = $image[0]; $thumbnail_url = $image[0];
} }
} }
printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $thumbnail_url ) ); printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $thumbnail_url ) );
printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_the_title() ) ); printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_the_title() ) );
printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( get_the_excerpt() ) ); printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( get_the_excerpt() ) );
printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) ); printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) );
} }
wp_head(); wp_head();
@@ -58,9 +58,9 @@ wp_head();
<body <?php body_class(); ?>> <body <?php body_class(); ?>>
<?php <?php
if ( function_exists( 'wp_body_open' ) ) { if ( function_exists( 'wp_body_open' ) ) {
wp_body_open(); wp_body_open();
} else { } else {
do_action( 'wp_body_open' ); // Backwards compatibility for < WP 5.2 do_action( 'wp_body_open' ); // Backwards compatibility for < WP 5.2
} }
do_action( 'sophia_after_dark_before_page' ); do_action( 'sophia_after_dark_before_page' );

View File

@@ -4,7 +4,6 @@
* *
* You can add an optional custom header image to header.php like so ... * You can add an optional custom header image to header.php like so ...
* *
*
* @link https://developer.wordpress.org/themes/functionality/custom-headers/ * @link https://developer.wordpress.org/themes/functionality/custom-headers/
* *
* @package Sophia After Dark * @package Sophia After Dark
@@ -18,15 +17,21 @@
* @uses sophia_after_dark_header_style() * @uses sophia_after_dark_header_style()
*/ */
function sophia_after_dark_custom_header_setup() { function sophia_after_dark_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'sophia_after_dark_custom_header_args', array( add_theme_support(
'default-image' => '', 'custom-header',
'default-text-color' => '000000', apply_filters(
'width' => 1000, 'sophia_after_dark_custom_header_args',
'height' => 250, array(
'flex-height' => true, 'default-image' => '',
'flex-width' => true, 'default-text-color' => '000000',
'wp-head-callback' => 'sophia_after_dark_header_style', 'width' => 1000,
) ) ); 'height' => 250,
'flex-height' => true,
'flex-width' => true,
'wp-head-callback' => 'sophia_after_dark_header_style',
)
)
);
} }
add_action( 'after_setup_theme', 'sophia_after_dark_custom_header_setup' ); add_action( 'after_setup_theme', 'sophia_after_dark_custom_header_setup' );
@@ -60,8 +65,8 @@ if ( ! function_exists( 'sophia_after_dark_header_style' ) ) :
position: absolute; position: absolute;
clip: rect(1px, 1px, 1px, 1px); clip: rect(1px, 1px, 1px, 1px);
} }
<?php <?php
// If the user has set a custom color for the text use that. // If the user has set a custom color for the text use that.
else : else :
?> ?>
.site-title a, .site-title a,

View File

@@ -8,7 +8,7 @@
if ( ! function_exists( 'sophia_after_dark_enable_top_header_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_enable_top_header_active_callback' ) ) :
/** /**
* Check if top header option is enabled. * Check if top header option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -17,19 +17,19 @@ if ( ! function_exists( 'sophia_after_dark_enable_top_header_active_callback' )
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_enable_top_header_active_callback( $control ) { function sophia_after_dark_enable_top_header_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_top_header' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_top_header' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_enable_top_header_trending_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_enable_top_header_trending_active_callback' ) ) :
/** /**
* Check if top header option and trending section option is enabled. * Check if top header option and trending section option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -38,40 +38,40 @@ if ( ! function_exists( 'sophia_after_dark_enable_top_header_trending_active_cal
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_enable_top_header_trending_active_callback( $control ) { function sophia_after_dark_enable_top_header_trending_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_top_header' )->value() && false !== $control->manager->get_setting( 'sophia_after_dark_enable_trending' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_top_header' )->value() && false !== $control->manager->get_setting( 'sophia_after_dark_enable_trending' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_enable_top_header_live_now_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_enable_top_header_live_now_active_callback' ) ) :
/** /**
* Check if top header option and trending section option is enabled. * Check if top header option and trending section option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
* *
* @param WP_Customize_Control $control WP_Customize_Control instance. * @param WP_Customize_Control $control WP_Customize_Control instance.
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_enable_top_header_live_now_active_callback( $control ) { function sophia_after_dark_enable_top_header_live_now_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_top_header' )->value() && false !== $control->manager->get_setting( 'sophia_after_dark_enable_live_now' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_top_header' )->value() && false !== $control->manager->get_setting( 'sophia_after_dark_enable_live_now' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_section_slider_option_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_section_slider_option_active_callback' ) ) :
/** /**
* Check if slider option is enabled. * Check if slider option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -80,19 +80,19 @@ if ( ! function_exists( 'sophia_after_dark_section_slider_option_active_callback
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_section_slider_option_active_callback( $control ) { function sophia_after_dark_section_slider_option_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_section_slider_option' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_section_slider_option' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_section_top_featured_posts_option_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_section_top_featured_posts_option_active_callback' ) ) :
/** /**
* Check if top featured posts option is enabled. * Check if top featured posts option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -101,19 +101,19 @@ if ( ! function_exists( 'sophia_after_dark_section_top_featured_posts_option_act
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_section_top_featured_posts_option_active_callback( $control ) { function sophia_after_dark_section_top_featured_posts_option_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_section_top_featured_posts_option' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_section_top_featured_posts_option' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_enable_footer_widget_area_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_enable_footer_widget_area_active_callback' ) ) :
/** /**
* Check if foooter menu option is enabled. * Check if foooter menu option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -122,19 +122,19 @@ if ( ! function_exists( 'sophia_after_dark_enable_footer_widget_area_active_call
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_enable_footer_widget_area_active_callback( $control ) { function sophia_after_dark_enable_footer_widget_area_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_footer_widget_area' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_footer_widget_area' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_enable_footer_menu_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_enable_footer_menu_active_callback' ) ) :
/** /**
* Check if foooter menu option is enabled. * Check if foooter menu option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -143,20 +143,20 @@ if ( ! function_exists( 'sophia_after_dark_enable_footer_menu_active_callback' )
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_enable_footer_menu_active_callback( $control ) { function sophia_after_dark_enable_footer_menu_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_footer_menu' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_footer_menu' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;
if ( ! function_exists( 'sophia_after_dark_enable_pnf_latest_posts_active_callback' ) ) : if ( ! function_exists( 'sophia_after_dark_enable_pnf_latest_posts_active_callback' ) ) :
/** /**
* Check if pnf latest posts option is enabled. * Check if pnf latest posts option is enabled.
* *
* @since 1.0.0 * @since 1.0.0
@@ -165,12 +165,12 @@ if ( ! function_exists( 'sophia_after_dark_enable_pnf_latest_posts_active_callba
* *
* @return bool Whether the control is active to the current preview. * @return bool Whether the control is active to the current preview.
*/ */
function sophia_after_dark_enable_pnf_latest_posts_active_callback( $control ) { function sophia_after_dark_enable_pnf_latest_posts_active_callback( $control ) {
if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_pnf_latest_posts' )->value() ) { if ( false !== $control->manager->get_setting( 'sophia_after_dark_enable_pnf_latest_posts' )->value() ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
endif; endif;

View File

@@ -8,21 +8,21 @@
add_action( 'customize_register', 'sophia_after_dark_customize_additinal_panels_sections_register' ); add_action( 'customize_register', 'sophia_after_dark_customize_additinal_panels_sections_register' );
/** /**
* Add Additional panels in the theme customize * Add Additional panels in the theme customize
*
*/ */
function sophia_after_dark_customize_additinal_panels_sections_register( $wp_customize ) { function sophia_after_dark_customize_additinal_panels_sections_register( $wp_customize ) {
/*------------------------------------------------ Social Icons Section ------------------------------------------------*/ /*------------------------------------------------ Social Icons Section ------------------------------------------------*/
/** /**
* Social Icons * Social Icons
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_social_icons', $wp_customize->add_section(
'sophia_after_dark_section_social_icons',
array( array(
'title' => esc_html__( 'Social Icons', 'sophia-after-dark' ), 'title' => esc_html__( 'Social Icons', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_additional_panel', 'panel' => 'sophia_after_dark_additional_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 5, 'priority' => 5,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
@@ -32,8 +32,9 @@ function sophia_after_dark_customize_additinal_panels_sections_register( $wp_cus
$wp_customize->add_setting( $wp_customize->add_setting(
'sophia_after_dark_social_icons', 'sophia_after_dark_social_icons',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => json_encode( array( 'default' => json_encode(
array(
array( array(
'social_icon' => 'fa fa-twitter', 'social_icon' => 'fa fa-twitter',
'social_url' => '#', 'social_url' => '#',
@@ -41,73 +42,77 @@ function sophia_after_dark_customize_additinal_panels_sections_register( $wp_cus
array( array(
'social_icon' => 'fa fa-pinterest', 'social_icon' => 'fa fa-pinterest',
'social_url' => '#', 'social_url' => '#',
) ),
) )
), ),
'sanitize_callback' => 'wp_kses_post' 'sanitize_callback' => 'wp_kses_post',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Repeater( $wp_customize->add_control(
$wp_customize, new Sophia_After_Dark_Control_Repeater(
$wp_customize,
'sophia_after_dark_social_icons', 'sophia_after_dark_social_icons',
array( array(
'label' => __( 'Social Media', 'sophia-after-dark' ), 'label' => __( 'Social Media', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_social_icons', 'section' => 'sophia_after_dark_section_social_icons',
'settings' => 'sophia_after_dark_social_icons', 'settings' => 'sophia_after_dark_social_icons',
'priority' => 5, 'priority' => 5,
'sophia_after_dark_box_label_text' => __( 'Social Media Icons','sophia-after-dark' ), 'sophia_after_dark_box_label_text' => __( 'Social Media Icons', 'sophia-after-dark' ),
'sophia_after_dark_box_add_control_text' => __( 'Add Icon','sophia-after-dark' ) 'sophia_after_dark_box_add_control_text' => __( 'Add Icon', 'sophia-after-dark' ),
), ),
array( array(
'social_icon' => array( 'social_icon' => array(
'type' => 'social_icon', 'type' => 'social_icon',
'label' => esc_html__( 'Social Icon', 'sophia-after-dark' ), 'label' => esc_html__( 'Social Icon', 'sophia-after-dark' ),
'description' => __( 'Choose social media icon.', 'sophia-after-dark' ) 'description' => __( 'Choose social media icon.', 'sophia-after-dark' ),
), ),
'social_url' => array( 'social_url' => array(
'type' => 'url', 'type' => 'url',
'label' => esc_html__( 'Social Link URL', 'sophia-after-dark' ), 'label' => esc_html__( 'Social Link URL', 'sophia-after-dark' ),
'description' => __( 'Enter social media url.', 'sophia-after-dark' ) 'description' => __( 'Enter social media url.', 'sophia-after-dark' ),
), ),
) )
) )
); );
/*------------------------------------------------ Breadcrumbs Section ------------------------------------------------* /*
------------------------------------------------ Breadcrumbs Section ------------------------------------------------*
/** /**
* Breadcrumbs * Breadcrumbs
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_breadcrumbs', $wp_customize->add_section(
'sophia_after_dark_section_breadcrumbs',
array( array(
'title' => esc_html__( 'Breadcrumbs', 'sophia-after-dark' ), 'title' => esc_html__( 'Breadcrumbs', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_additional_panel', 'panel' => 'sophia_after_dark_additional_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 10, 'priority' => 10,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
/** /**
* Toggle field for Enable/Disable breadcrumbs. * Toggle field for Enable/Disable breadcrumbs.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_breadcrumb_option', $wp_customize->add_setting(
'sophia_after_dark_enable_breadcrumb_option',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_breadcrumb_option', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_breadcrumb_option',
array( array(
'label' => __( 'Enable Breadcrumbs', 'sophia-after-dark' ), 'label' => __( 'Enable Breadcrumbs', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_breadcrumbs', 'section' => 'sophia_after_dark_section_breadcrumbs',
'settings' => 'sophia_after_dark_enable_breadcrumb_option', 'settings' => 'sophia_after_dark_enable_breadcrumb_option',
'priority' => 5, 'priority' => 5,
) )
) )
); );
} }

View File

@@ -8,14 +8,14 @@
add_action( 'customize_register', 'sophia_after_dark_register_custom_controls' ); add_action( 'customize_register', 'sophia_after_dark_register_custom_controls' );
if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) : if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
/** /**
* Register Custom Controls * Register Custom Controls
* *
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_register_custom_controls( $wp_customize ) { function sophia_after_dark_register_custom_controls( $wp_customize ) {
if ( ! class_exists( 'sophia_after_dark_Control_Toggle' ) ) { if ( ! class_exists( 'sophia_after_dark_Control_Toggle' ) ) {
/** /**
* Toggle control (modified checkbox) * Toggle control (modified checkbox)
*/ */
@@ -36,7 +36,7 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
if ( isset( $this->default ) ) { if ( isset( $this->default ) ) {
$this->json['default'] = $this->default; $this->json['default'] = $this->default;
} else{ } else {
$this->json['default'] = $this->setting->default; $this->json['default'] = $this->setting->default;
} }
@@ -71,12 +71,12 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
} }
} //Ends sophia_after_dark_Control_Toggle } //Ends sophia_after_dark_Control_Toggle
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
if ( ! class_exists( 'sophia_after_dark_Control_Radio_Image' ) ) { if ( ! class_exists( 'sophia_after_dark_Control_Radio_Image' ) ) {
/** /**
* Radio Image control (modified radio). * Radio Image control (modified radio).
*/ */
class Sophia_After_Dark_Control_Radio_Image extends WP_Customize_Control { class Sophia_After_Dark_Control_Radio_Image extends WP_Customize_Control {
/** /**
@@ -141,12 +141,12 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
} }
} }
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
if ( ! class_exists( 'sophia_after_dark_Control_Repeater' ) ) { if ( ! class_exists( 'sophia_after_dark_Control_Repeater' ) ) {
/** /**
* Repeater control * Repeater control
*/ */
class Sophia_After_Dark_Control_Repeater extends WP_Customize_Control { class Sophia_After_Dark_Control_Repeater extends WP_Customize_Control {
/** /**
@@ -176,18 +176,18 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
*/ */
public function __construct( $manager, $id, $args = array(), $fields = array() ) { public function __construct( $manager, $id, $args = array(), $fields = array() ) {
$this->fields = $fields; $this->fields = $fields;
$this->sophia_after_dark_box_label = $args['sophia_after_dark_box_label_text'] ; $this->sophia_after_dark_box_label = $args['sophia_after_dark_box_label_text'];
$this->sophia_after_dark_box_add_control = $args['sophia_after_dark_box_add_control_text']; $this->sophia_after_dark_box_add_control = $args['sophia_after_dark_box_add_control_text'];
parent::__construct( $manager, $id, $args ); parent::__construct( $manager, $id, $args );
} }
protected function render_content() { protected function render_content() {
$values = json_decode( $this->value() ); $values = json_decode( $this->value() );
$repeater_id = $this->id; $repeater_id = $this->id;
$field_count = count( $values ); $field_count = count( $values );
?> ?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php if ( $this->description ) { ?> <?php if ( $this->description ) { ?>
@@ -201,10 +201,10 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
</ul> </ul>
<input type="hidden" <?php $this->link(); ?> class="sad-repeater-collector" value="<?php echo esc_attr( $this->value() ); ?>" /> <input type="hidden" <?php $this->link(); ?> class="sad-repeater-collector" value="<?php echo esc_attr( $this->value() ); ?>" />
<input type="hidden" name="<?php echo esc_attr( $repeater_id ).'_count'; ?>" class="field-count" value="<?php echo absint( $field_count ); ?>"> <input type="hidden" name="<?php echo esc_attr( $repeater_id ) . '_count'; ?>" class="field-count" value="<?php echo absint( $field_count ); ?>">
<input type="hidden" name="field_limit" class="field-limit" value="6"> <input type="hidden" name="field_limit" class="field-limit" value="6">
<button type="button" class="button sad-repeater-add-control-field"><?php echo esc_html( $this->sophia_after_dark_box_add_control ); ?></button> <button type="button" class="button sad-repeater-add-control-field"><?php echo esc_html( $this->sophia_after_dark_box_add_control ); ?></button>
<?php <?php
} }
private function sophia_after_dark_get_fields() { private function sophia_after_dark_get_fields() {
@@ -212,50 +212,50 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
$values = json_decode( $this->value() ); $values = json_decode( $this->value() );
if ( is_array( $values ) ) { if ( is_array( $values ) ) {
foreach( $values as $value ) { foreach ( $values as $value ) {
?> ?>
<li class="sad-repeater-field-control"> <li class="sad-repeater-field-control">
<h3 class="sad-repeater-field-title"><?php echo esc_html( $this->sophia_after_dark_box_label ); ?></h3> <h3 class="sad-repeater-field-title"><?php echo esc_html( $this->sophia_after_dark_box_label ); ?></h3>
<div class="sad-repeater-fields"> <div class="sad-repeater-fields">
<?php
foreach ( $fields as $key => $field ) {
$class = isset( $field['class'] ) ? $field['class'] : '';
?>
<div class="sad-repeater-field sad-repeater-type-<?php echo esc_attr( $field['type'] ).' '.esc_attr( $class ); ?>">
<?php <?php
$label = isset( $field['label'] ) ? $field['label'] : ''; foreach ( $fields as $key => $field ) {
$class = isset( $field['class'] ) ? $field['class'] : '';
?>
<div class="sad-repeater-field sad-repeater-type-<?php echo esc_attr( $field['type'] ) . ' ' . esc_attr( $class ); ?>">
<?php
$label = isset( $field['label'] ) ? $field['label'] : '';
$description = isset( $field['description'] ) ? $field['description'] : ''; $description = isset( $field['description'] ) ? $field['description'] : '';
if ( $field['type'] != 'checkbox' ) { if ( $field['type'] != 'checkbox' ) {
?> ?>
<span class="customize-control-title"><?php echo esc_html( $label ); ?></span> <span class="customize-control-title"><?php echo esc_html( $label ); ?></span>
<span class="description customize-control-description"><?php echo esc_html( $description ); ?></span> <span class="description customize-control-description"><?php echo esc_html( $description ); ?></span>
<?php <?php
} }
$new_value = isset( $value->$key ) ? $value->$key : ''; $new_value = isset( $value->$key ) ? $value->$key : '';
$default = isset( $field['default'] ) ? $field['default'] : ''; $default = isset( $field['default'] ) ? $field['default'] : '';
switch ( $field['type'] ) { switch ( $field['type'] ) {
/** /**
* Text field * Text field
*/ */
case 'text': case 'text':
echo '<input data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'" type="text" value="'.esc_attr( $new_value ).'"/>'; echo '<input data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '" type="text" value="' . esc_attr( $new_value ) . '"/>';
break; break;
/** /**
* Textarea field * Textarea field
*/ */
case 'textarea': case 'textarea':
echo '<textarea data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'">'.esc_attr( $new_value ).'</textarea>'; echo '<textarea data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '">' . esc_attr( $new_value ) . '</textarea>';
break; break;
/** /**
* URL field * URL field
*/ */
case 'url': case 'url':
echo '<input data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'" type="text" value="'.esc_url( $new_value ).'"/>'; echo '<input data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '" type="text" value="' . esc_url( $new_value ) . '"/>';
break; break;
/** /**
@@ -263,12 +263,12 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
*/ */
case 'icon': case 'icon':
$sophia_after_dark_fork_awesome_icon_array = sophia_after_dark_fork_awesome_icon_array(); $sophia_after_dark_fork_awesome_icon_array = sophia_after_dark_fork_awesome_icon_array();
echo '<div class="sad-repeater-selected-icon"><i class="'.esc_attr( $new_value ).'"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">'; echo '<div class="sad-repeater-selected-icon"><i class="' . esc_attr( $new_value ) . '"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">';
foreach ( $sophia_after_dark_fork_awesome_icon_array as $sophia_after_dark_fork_awesome_icon ) { foreach ( $sophia_after_dark_fork_awesome_icon_array as $sophia_after_dark_fork_awesome_icon ) {
$icon_class = $new_value == $sophia_after_dark_fork_awesome_icon ? 'icon-active' : ''; $icon_class = $new_value == $sophia_after_dark_fork_awesome_icon ? 'icon-active' : '';
echo '<li class='.esc_attr( $icon_class ).'><i class="'.esc_attr( $sophia_after_dark_fork_awesome_icon ).'"></i></li>'; echo '<li class=' . esc_attr( $icon_class ) . '><i class="' . esc_attr( $sophia_after_dark_fork_awesome_icon ) . '"></i></li>';
} }
echo '</ul><input data-default="'.esc_attr( $default ).'" type="hidden" value="'.esc_attr( $new_value ).'" data-name="'.esc_attr( $key ).'"/>'; echo '</ul><input data-default="' . esc_attr( $default ) . '" type="hidden" value="' . esc_attr( $new_value ) . '" data-name="' . esc_attr( $key ) . '"/>';
break; break;
/** /**
@@ -276,12 +276,12 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
*/ */
case 'social_icon': case 'social_icon':
$sophia_after_dark_fork_awesome_social_icon_array = sophia_after_dark_fork_awesome_social_icon_array(); $sophia_after_dark_fork_awesome_social_icon_array = sophia_after_dark_fork_awesome_social_icon_array();
echo '<div class="sad-repeater-selected-icon"><i class="'.esc_attr( $new_value ).'"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">'; echo '<div class="sad-repeater-selected-icon"><i class="' . esc_attr( $new_value ) . '"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">';
foreach ( $sophia_after_dark_fork_awesome_social_icon_array as $sophia_after_dark_fork_awesome_icon ) { foreach ( $sophia_after_dark_fork_awesome_social_icon_array as $sophia_after_dark_fork_awesome_icon ) {
$icon_class = $new_value == $sophia_after_dark_fork_awesome_icon ? 'icon-active' : ''; $icon_class = $new_value == $sophia_after_dark_fork_awesome_icon ? 'icon-active' : '';
echo '<li class='.esc_attr( $icon_class ).'><i class="'.esc_attr( $sophia_after_dark_fork_awesome_icon ).'"></i></li>'; echo '<li class=' . esc_attr( $icon_class ) . '><i class="' . esc_attr( $sophia_after_dark_fork_awesome_icon ) . '"></i></li>';
} }
echo '</ul><input data-default="'.esc_attr( $default ).'" type="hidden" value="'.esc_attr( $new_value ).'" data-name="'.esc_attr( $key ).'"/>'; echo '</ul><input data-default="' . esc_attr( $default ) . '" type="hidden" value="' . esc_attr( $new_value ) . '" data-name="' . esc_attr( $key ) . '"/>';
break; break;
/** /**
@@ -289,11 +289,10 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
*/ */
case 'select': case 'select':
$options = $field['options']; $options = $field['options'];
echo '<select data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'">'; echo '<select data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '">';
foreach ( $options as $option => $val ) foreach ( $options as $option => $val ) {
{ printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $option ), selected( $new_value, $option, false ), esc_html( $val ) );
printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $option ), selected( $new_value, $option, false ), esc_html( $val ) ); }
}
echo '</select>'; echo '</select>';
break; break;
@@ -301,21 +300,21 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
* Dropdown field * Dropdown field
*/ */
case 'dropdown_pages': case 'dropdown_pages':
$show_option_none = esc_html__( '&mdash; Select a page &mdash;', 'sophia-after-dark' ); $show_option_none = esc_html__( '&mdash; Select a page &mdash;', 'sophia-after-dark' );
$select_field ='data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'"'; $select_field = 'data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '"';
$option_none_value = ''; $option_none_value = '';
$dropdown = wp_dropdown_pages( $dropdown = wp_dropdown_pages(
array( array(
'name' => esc_attr( $key ), 'name' => esc_attr( $key ),
'echo' => '', 'echo' => '',
'show_option_none' => esc_html( $show_option_none ), 'show_option_none' => esc_html( $show_option_none ),
'option_none_value' => esc_attr( $option_none_value ), 'option_none_value' => esc_attr( $option_none_value ),
'selected' => esc_attr( $new_value ) 'selected' => esc_attr( $new_value ),
) )
); );
if ( empty( $dropdown ) ) { if ( empty( $dropdown ) ) {
$dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $key ) ); $dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $key ) );
$dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) ); $dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
$dropdown .= '</select>'; $dropdown .= '</select>';
} }
@@ -329,39 +328,39 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
* Upload field * Upload field
*/ */
case 'upload': case 'upload':
$image_class = ""; $image_class = '';
$upload_btn_label = esc_html__( 'Select Image', 'sophia-after-dark' ); $upload_btn_label = esc_html__( 'Select Image', 'sophia-after-dark' );
$remove_btn_label = esc_html__( 'Remove', 'sophia-after-dark' ); $remove_btn_label = esc_html__( 'Remove', 'sophia-after-dark' );
if ( $new_value ) { if ( $new_value ) {
$image_class = ' hidden'; $image_class = ' hidden';
} }
echo '<div class="sad-fields-wrap"><div class="attachment-media-view"><div class="placeholder'. esc_attr( $image_class ).'">'; echo '<div class="sad-fields-wrap"><div class="attachment-media-view"><div class="placeholder' . esc_attr( $image_class ) . '">';
esc_html_e( 'No image selected', 'sophia-after-dark' ); esc_html_e( 'No image selected', 'sophia-after-dark' );
echo '</div><div class="thumbnail thumbnail-image"><img src="'.esc_url( $new_value ).'" style="max-width:100%;"/></div><div class="actions sad-clearfix"><button type="button" class="button sad-delete-button align-left">'. esc_html( $remove_btn_label ) .'</button><button type="button" class="button sad-upload-button alignright">'. esc_html( $upload_btn_label ) .'</button><input data-default="'.esc_attr( $default ).'" class="upload-id" data-name="'.esc_attr( $key ).'" type="hidden" value="'.esc_attr( $new_value ).'"/></div></div></div>'; echo '</div><div class="thumbnail thumbnail-image"><img src="' . esc_url( $new_value ) . '" style="max-width:100%;"/></div><div class="actions sad-clearfix"><button type="button" class="button sad-delete-button align-left">' . esc_html( $remove_btn_label ) . '</button><button type="button" class="button sad-upload-button alignright">' . esc_html( $upload_btn_label ) . '</button><input data-default="' . esc_attr( $default ) . '" class="upload-id" data-name="' . esc_attr( $key ) . '" type="hidden" value="' . esc_attr( $new_value ) . '"/></div></div></div>';
break; break;
default: default:
break; break;
} }
?> ?>
</div> </div>
<?php <?php
} }
?> ?>
<div class="sad-clearfix sad-repeater-footer"> <div class="sad-clearfix sad-repeater-footer">
<div class="alignright"> <div class="alignright">
<a class="sad-repeater-field-remove" href="#remove"><?php esc_html_e( 'Delete', 'sophia-after-dark' ) ?></a> | <a class="sad-repeater-field-remove" href="#remove"><?php esc_html_e( 'Delete', 'sophia-after-dark' ); ?></a> |
<a class="sad-repeater-field-close" href="#close"><?php esc_html_e( 'Close', 'sophia-after-dark' ) ?></a> <a class="sad-repeater-field-close" href="#close"><?php esc_html_e( 'Close', 'sophia-after-dark' ); ?></a>
</div> </div>
</div> </div>
</div> </div>
</li> </li>
<?php <?php
} }
} }
} }
} }
} }
}// Ends sophia_after_dark_register_custom_controls }//end sophia_after_dark_register_custom_controls()
endif; endif;
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/

View File

@@ -9,45 +9,47 @@
add_action( 'customize_register', 'sophia_after_dark_customize_design_panels_sections_register' ); add_action( 'customize_register', 'sophia_after_dark_customize_design_panels_sections_register' );
/** /**
* Add Additional panels in the theme customizer * Add Additional panels in the theme customizer
*
*/ */
function sophia_after_dark_customize_design_panels_sections_register( $wp_customize ) { function sophia_after_dark_customize_design_panels_sections_register( $wp_customize ) {
/*------------------------------------------------ Archive Section ------------------------------------------------------------*/ /*------------------------------------------------ Archive Section ------------------------------------------------------------*/
/** /**
* Archive Settings * Archive Settings
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_archive_settings', $wp_customize->add_section(
'sophia_after_dark_section_archive_settings',
array( array(
'title' => esc_html__( 'Archive Settings', 'sophia-after-dark' ), 'title' => esc_html__( 'Archive Settings', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_design_panel', 'panel' => 'sophia_after_dark_design_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 5, 'priority' => 5,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
/* /*
* Radio Image field for archive/blog sidebar layout. * Radio Image field for archive/blog sidebar layout.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_archive_sidebar_layout', $wp_customize->add_setting(
'sophia_after_dark_archive_sidebar_layout',
array( array(
'default' => 'no-sidebar', 'default' => 'no-sidebar',
'sanitize_callback' => 'sanitize_key', 'sanitize_callback' => 'sanitize_key',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Radio_Image( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_archive_sidebar_layout', new Sophia_After_Dark_Control_Radio_Image(
$wp_customize,
'sophia_after_dark_archive_sidebar_layout',
array( array(
'label' => esc_html__( 'Archive/Blog Sidebar Layout', 'sophia-after-dark' ), 'label' => esc_html__( 'Archive/Blog Sidebar Layout', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_archive_settings', 'section' => 'sophia_after_dark_section_archive_settings',
'settings' => 'sophia_after_dark_archive_sidebar_layout', 'settings' => 'sophia_after_dark_archive_sidebar_layout',
'priority' => 10, 'priority' => 10,
'choices' => array( 'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png', 'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png', 'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png', 'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
'no-sidebar-center' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png' 'no-sidebar-center' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png',
), ),
) )
) )
@@ -56,20 +58,23 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/* /*
* Radio Image field for arvhive/blog style. * Radio Image field for arvhive/blog style.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_archive_style', $wp_customize->add_setting(
'sophia_after_dark_archive_style',
array( array(
'default' => 'sad-archive--masonry-style', 'default' => 'sad-archive--masonry-style',
'sanitize_callback' => 'sanitize_key', 'sanitize_callback' => 'sanitize_key',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Radio_Image( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_archive_style', new Sophia_After_Dark_Control_Radio_Image(
$wp_customize,
'sophia_after_dark_archive_style',
array( array(
'label' => esc_html__( 'Archive/Blog Style', 'sophia-after-dark' ), 'label' => esc_html__( 'Archive/Blog Style', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_archive_settings', 'section' => 'sophia_after_dark_section_archive_settings',
'settings' => 'sophia_after_dark_archive_style', 'settings' => 'sophia_after_dark_archive_style',
'priority' => 10, 'priority' => 10,
'choices' => array( 'choices' => array(
'sad-archive--block-grid-style' => get_template_directory_uri() . '/assets/images/archive-block-grid.png', 'sad-archive--block-grid-style' => get_template_directory_uri() . '/assets/images/archive-block-grid.png',
'sad-archive--masonry-style' => get_template_directory_uri() . '/assets/images/archive-masonry.png', 'sad-archive--masonry-style' => get_template_directory_uri() . '/assets/images/archive-masonry.png',
), ),
@@ -80,44 +85,48 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/* /*
* Text field for archive read more button. * Text field for archive read more button.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_archive_read_more', $wp_customize->add_setting(
'sophia_after_dark_archive_read_more',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( 'Discover', 'sophia-after-dark' ), 'default' => esc_html__( 'Discover', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_archive_read_more', $wp_customize->add_control(
'sophia_after_dark_archive_read_more',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Read More Button', 'sophia-after-dark' ), 'label' => esc_html__( 'Read More Button', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_archive_settings', 'section' => 'sophia_after_dark_section_archive_settings',
'settings' => 'sophia_after_dark_archive_read_more', 'settings' => 'sophia_after_dark_archive_read_more',
'priority' => 15, 'priority' => 15,
) )
); );
/** /**
* Toggle field for Enable/Disable title prefix at category pages. * Toggle field for Enable/Disable title prefix at category pages.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_archive_title_prefix', $wp_customize->add_setting(
'sophia_after_dark_enable_archive_title_prefix',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_archive_title_prefix', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_archive_title_prefix',
array( array(
'label' => __( 'Enable Title Prefix', 'sophia-after-dark' ), 'label' => __( 'Enable Title Prefix', 'sophia-after-dark' ),
'description' => esc_html__( 'Show/Hide title prefix in archive pages.', 'sophia-after-dark' ), 'description' => esc_html__( 'Show/Hide title prefix in archive pages.', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_archive_settings', 'section' => 'sophia_after_dark_section_archive_settings',
'settings' => 'sophia_after_dark_enable_archive_title_prefix', 'settings' => 'sophia_after_dark_enable_archive_title_prefix',
'priority' => 20, 'priority' => 20,
) )
) )
); );
@@ -126,36 +135,40 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/** /**
* Post Settings * Post Settings
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_post_settings', $wp_customize->add_section(
'sophia_after_dark_section_post_settings',
array( array(
'title' => esc_html__( 'Post Settings', 'sophia-after-dark' ), 'title' => esc_html__( 'Post Settings', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_design_panel', 'panel' => 'sophia_after_dark_design_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 10, 'priority' => 10,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
/* /*
* Radio Image field for single posts sidebar layout. * Radio Image field for single posts sidebar layout.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_posts_sidebar_layout', $wp_customize->add_setting(
'sophia_after_dark_posts_sidebar_layout',
array( array(
'default' => 'right-sidebar', 'default' => 'right-sidebar',
'sanitize_callback' => 'sanitize_key', 'sanitize_callback' => 'sanitize_key',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Radio_Image( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_posts_sidebar_layout', new Sophia_After_Dark_Control_Radio_Image(
$wp_customize,
'sophia_after_dark_posts_sidebar_layout',
array( array(
'label' => esc_html__( 'Posts Sidebar Layout', 'sophia-after-dark' ), 'label' => esc_html__( 'Posts Sidebar Layout', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_post_settings', 'section' => 'sophia_after_dark_section_post_settings',
'settings' => 'sophia_after_dark_posts_sidebar_layout', 'settings' => 'sophia_after_dark_posts_sidebar_layout',
'priority' => 5, 'priority' => 5,
'choices' => array( 'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png', 'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png', 'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png', 'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
'no-sidebar-center' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png' 'no-sidebar-center' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png',
), ),
) )
) )
@@ -164,21 +177,24 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/* /*
* Toggle field for Enable/Disable related posts. * Toggle field for Enable/Disable related posts.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_related_posts', $wp_customize->add_setting(
'sophia_after_dark_enable_related_posts',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_related_posts', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_related_posts',
array( array(
'label' => esc_html__( 'Enable Related Posts', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Related Posts', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_post_settings', 'section' => 'sophia_after_dark_section_post_settings',
'settings' => 'sophia_after_dark_enable_related_posts', 'settings' => 'sophia_after_dark_enable_related_posts',
'priority' => 15, 'priority' => 15,
) )
) )
); );
@@ -187,37 +203,41 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/** /**
* Page Setting * Page Setting
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_page_settings', $wp_customize->add_section(
'sophia_after_dark_section_page_settings',
array( array(
'title' => esc_html__( 'Page Settings', 'sophia-after-dark' ), 'title' => esc_html__( 'Page Settings', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_design_panel', 'panel' => 'sophia_after_dark_design_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 15, 'priority' => 15,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
/* /*
* Radio Image field for single page sidebar layout. * Radio Image field for single page sidebar layout.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_pages_sidebar_layout', $wp_customize->add_setting(
'sophia_after_dark_pages_sidebar_layout',
array( array(
'default' => 'right-sidebar', 'default' => 'right-sidebar',
'sanitize_callback' => 'sanitize_key', 'sanitize_callback' => 'sanitize_key',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Radio_Image( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_pages_sidebar_layout', new Sophia_After_Dark_Control_Radio_Image(
$wp_customize,
'sophia_after_dark_pages_sidebar_layout',
array( array(
'label' => esc_html__( 'Pages Sidebar Layout', 'sophia-after-dark' ), 'label' => esc_html__( 'Pages Sidebar Layout', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_page_settings', 'section' => 'sophia_after_dark_section_page_settings',
'settings' => 'sophia_after_dark_pages_sidebar_layout', 'settings' => 'sophia_after_dark_pages_sidebar_layout',
'priority' => 5, 'priority' => 5,
'choices' => array( 'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png', 'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png', 'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png', 'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
'no-sidebar-center' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png' 'no-sidebar-center' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png',
), ),
) )
) )
@@ -227,34 +247,38 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/** /**
* 404 Page Settings * 404 Page Settings
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_pnf_settings', $wp_customize->add_section(
'sophia_after_dark_section_pnf_settings',
array( array(
'priority' => 20, 'priority' => 20,
'panel' => 'sophia_after_dark_design_panel', 'panel' => 'sophia_after_dark_design_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( '404 Page Settings', 'sophia-after-dark' ) 'title' => __( '404 Page Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Toggle field for Enable/Disable latest posts section at 404 page * Toggle field for Enable/Disable latest posts section at 404 page
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_pnf_latest_posts', $wp_customize->add_setting(
'sophia_after_dark_enable_pnf_latest_posts',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_pnf_latest_posts', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_pnf_latest_posts',
array( array(
'label' => __( 'Enable Latest Posts', 'sophia-after-dark' ), 'label' => __( 'Enable Latest Posts', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_pnf_settings', 'section' => 'sophia_after_dark_section_pnf_settings',
'settings' => 'sophia_after_dark_enable_pnf_latest_posts', 'settings' => 'sophia_after_dark_enable_pnf_latest_posts',
'priority' => 40, 'priority' => 40,
) )
) )
); );
@@ -262,42 +286,46 @@ function sophia_after_dark_customize_design_panels_sections_register( $wp_custom
/** /**
* Text field for latest posts section title * Text field for latest posts section title
*/ */
$wp_customize->add_setting( 'sophia_after_dark_pnf_latest_title', $wp_customize->add_setting(
'sophia_after_dark_pnf_latest_title',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( 'You May Like', 'sophia-after-dark' ), 'default' => esc_html__( 'You May Like', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_pnf_latest_title', $wp_customize->add_control(
'sophia_after_dark_pnf_latest_title',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Section Title', 'sophia-after-dark' ), 'label' => esc_html__( 'Section Title', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_pnf_settings', 'section' => 'sophia_after_dark_section_pnf_settings',
'priority' => 45, 'priority' => 45,
'active_callback' => 'sophia_after_dark_enable_pnf_latest_posts_active_callback', 'active_callback' => 'sophia_after_dark_enable_pnf_latest_posts_active_callback',
) )
); );
/** /**
* Text field for latest posts count * Text field for latest posts count
*/ */
$wp_customize->add_setting( 'sophia_after_dark_pnf_latest_post_count', $wp_customize->add_setting(
'sophia_after_dark_pnf_latest_post_count',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => 3, 'default' => 3,
'sanitize_callback' => 'absint', 'sanitize_callback' => 'absint',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_pnf_latest_post_count', $wp_customize->add_control(
'sophia_after_dark_pnf_latest_post_count',
array( array(
'type' => 'number', 'type' => 'number',
'label' => esc_html__( 'Post count', 'sophia-after-dark' ), 'label' => esc_html__( 'Post count', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_pnf_settings', 'section' => 'sophia_after_dark_section_pnf_settings',
'priority' => 50, 'priority' => 50,
'active_callback' => 'sophia_after_dark_enable_pnf_latest_posts_active_callback', 'active_callback' => 'sophia_after_dark_enable_pnf_latest_posts_active_callback',
) )
); );
} }

View File

@@ -9,41 +9,44 @@
add_action( 'customize_register', 'sophia_after_dark_customize_footer_panels_sections_register' ); add_action( 'customize_register', 'sophia_after_dark_customize_footer_panels_sections_register' );
/** /**
* Add Additional panels in the theme customizer * Add Additional panels in the theme customizer
*
*/ */
function sophia_after_dark_customize_footer_panels_sections_register( $wp_customize ) { function sophia_after_dark_customize_footer_panels_sections_register( $wp_customize ) {
/*------------------------------------------------------- Footer Widget Area Section --------------------------------------------------------------------------*/ /*------------------------------------------------------- Footer Widget Area Section --------------------------------------------------------------------------*/
/** /**
* Footer Widget Area * Footer Widget Area
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_footer_widget_area', $wp_customize->add_section(
'sophia_after_dark_section_footer_widget_area',
array( array(
'title' => esc_html__( 'Footer Widget Area', 'sophia-after-dark' ), 'title' => esc_html__( 'Footer Widget Area', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_footer_panel', 'panel' => 'sophia_after_dark_footer_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 5, 'priority' => 5,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
/** /**
* Toggle field for Enable/Disable footer widget area. * Toggle field for Enable/Disable footer widget area.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_footer_widget_area', $wp_customize->add_setting(
'sophia_after_dark_enable_footer_widget_area',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_footer_widget_area', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_footer_widget_area',
array( array(
'label' => esc_html__( 'Enable Footer Widget Area', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Footer Widget Area', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_footer_widget_area', 'section' => 'sophia_after_dark_section_footer_widget_area',
'settings' => 'sophia_after_dark_enable_footer_widget_area', 'settings' => 'sophia_after_dark_enable_footer_widget_area',
'priority' => 5, 'priority' => 5,
) )
) )
); );
@@ -51,26 +54,29 @@ function sophia_after_dark_customize_footer_panels_sections_register( $wp_custom
/** /**
* Radio Image field for Widget Area layout * Radio Image field for Widget Area layout
*/ */
$wp_customize->add_setting( 'sophia_after_dark_widget_area_layout', $wp_customize->add_setting(
'sophia_after_dark_widget_area_layout',
array( array(
'default' => 'column-three', 'default' => 'column-three',
'sanitize_callback' => 'sanitize_key', 'sanitize_callback' => 'sanitize_key',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Radio_Image( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_widget_area_layout', new Sophia_After_Dark_Control_Radio_Image(
$wp_customize,
'sophia_after_dark_widget_area_layout',
array( array(
'label' => esc_html__( 'Widget Area Layout', 'sophia-after-dark' ), 'label' => esc_html__( 'Widget Area Layout', 'sophia-after-dark' ),
'description' => __( 'Choose widget layout from available layouts', 'sophia-after-dark' ), 'description' => __( 'Choose widget layout from available layouts', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_footer_widget_area', 'section' => 'sophia_after_dark_section_footer_widget_area',
'settings' => 'sophia_after_dark_widget_area_layout', 'settings' => 'sophia_after_dark_widget_area_layout',
'priority' => 15, 'priority' => 15,
'active_callback' => 'sophia_after_dark_enable_footer_widget_area_active_callback', 'active_callback' => 'sophia_after_dark_enable_footer_widget_area_active_callback',
'choices' => array( 'choices' => array(
'column-four' => get_template_directory_uri() . '/assets/images/footer-4.png', 'column-four' => get_template_directory_uri() . '/assets/images/footer-4.png',
'column-three' => get_template_directory_uri() . '/assets/images/footer-3.png', 'column-three' => get_template_directory_uri() . '/assets/images/footer-3.png',
'column-two' => get_template_directory_uri() . '/assets/images/footer-2.png', 'column-two' => get_template_directory_uri() . '/assets/images/footer-2.png',
'column-one' => get_template_directory_uri() . '/assets/images/footer-1.png' 'column-one' => get_template_directory_uri() . '/assets/images/footer-1.png',
), ),
) )
) )
@@ -80,77 +86,84 @@ function sophia_after_dark_customize_footer_panels_sections_register( $wp_custom
/** /**
* Bottom footer * Bottom footer
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_bottom_footer', $wp_customize->add_section(
'sophia_after_dark_section_bottom_footer',
array( array(
'title' => esc_html__( 'Bottom Footer', 'sophia-after-dark' ), 'title' => esc_html__( 'Bottom Footer', 'sophia-after-dark' ),
'panel' => 'sophia_after_dark_footer_panel', 'panel' => 'sophia_after_dark_footer_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'priority' => 10, 'priority' => 10,
'theme_supports' => '', 'theme_supports' => '',
) )
); );
/** /**
* Toggle field for Enable/Disable footer menu. * Toggle field for Enable/Disable footer menu.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_footer_menu', $wp_customize->add_setting(
'sophia_after_dark_enable_footer_menu',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_footer_menu', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_footer_menu',
array( array(
'label' => esc_html__( 'Enable Footer Menu', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Footer Menu', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_bottom_footer', 'section' => 'sophia_after_dark_section_bottom_footer',
'settings' => 'sophia_after_dark_enable_footer_menu', 'settings' => 'sophia_after_dark_enable_footer_menu',
'priority' => 5, 'priority' => 5,
) )
) )
); );
/** /**
* Text filed for copyright * Text filed for copyright
*/ */
$wp_customize->add_setting( 'sophia_after_dark_footer_copyright', $wp_customize->add_setting(
'sophia_after_dark_footer_copyright',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( '&copy;1969 Sophia After Dark', 'sophia-after-dark' ), 'default' => esc_html__( '&copy;1969 Sophia After Dark', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_footer_copyright', $wp_customize->add_control(
'sophia_after_dark_footer_copyright',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Copyright Text', 'sophia-after-dark' ), 'label' => esc_html__( 'Copyright Text', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_bottom_footer', 'section' => 'sophia_after_dark_section_bottom_footer',
'priority' => 25, 'priority' => 25,
'active_callback' => 'sophia_after_dark_enable_footer_menu_active_callback', 'active_callback' => 'sophia_after_dark_enable_footer_menu_active_callback',
) )
); );
/** /**
* Text filed for disclaimer * Text filed for disclaimer
*/ */
$wp_customize->add_setting( 'sophia_after_dark_footer_disclaimer', $wp_customize->add_setting(
'sophia_after_dark_footer_disclaimer',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( 'All Trademarks are property of their respective owners', 'sophia-after-dark' ), 'default' => esc_html__( 'All Trademarks are property of their respective owners', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_footer_disclaimer', $wp_customize->add_control(
'sophia_after_dark_footer_disclaimer',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Disclaimer Text', 'sophia-after-dark' ), 'label' => esc_html__( 'Disclaimer Text', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_bottom_footer', 'section' => 'sophia_after_dark_section_bottom_footer',
'priority' => 25, 'priority' => 25,
'active_callback' => 'sophia_after_dark_enable_footer_menu_active_callback', 'active_callback' => 'sophia_after_dark_enable_footer_menu_active_callback',
) )
); );
} }

View File

@@ -9,7 +9,6 @@
add_action( 'customize_register', 'sophia_after_dark_customize_slider_panels_sections_register' ); add_action( 'customize_register', 'sophia_after_dark_customize_slider_panels_sections_register' );
/** /**
* Add panels in the theme customizer * Add panels in the theme customizer
*
*/ */
function sophia_after_dark_customize_slider_panels_sections_register( $wp_customize ) { function sophia_after_dark_customize_slider_panels_sections_register( $wp_customize ) {
@@ -17,83 +16,90 @@ function sophia_after_dark_customize_slider_panels_sections_register( $wp_custom
/** /**
* Slider Settings * Slider Settings
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_slider', $wp_customize->add_section(
'sophia_after_dark_section_slider',
array( array(
'priority' => 10, 'priority' => 10,
'panel' => 'sophia_after_dark_front_section_panel', 'panel' => 'sophia_after_dark_front_section_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Slider Settings', 'sophia-after-dark' ) 'title' => __( 'Slider Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Toggle field for slider option * Toggle field for slider option
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_section_slider_option', $wp_customize->add_setting(
'sophia_after_dark_section_slider_option',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => false, 'default' => false,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_section_slider_option', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_section_slider_option',
array( array(
'label' => __( 'Enable Slider Section', 'sophia-after-dark' ), 'label' => __( 'Enable Slider Section', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_slider', 'section' => 'sophia_after_dark_section_slider',
'settings' => 'sophia_after_dark_section_slider_option', 'settings' => 'sophia_after_dark_section_slider_option',
'priority' => 5, 'priority' => 5,
) )
) )
); );
/** /**
* Select field for slider cat select * Select field for slider cat select
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_section_slider_cat', $wp_customize->add_setting(
'sophia_after_dark_section_slider_cat',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => '', 'default' => '',
'sanitize_callback' => 'sophia_after_dark_sanitize_select', 'sanitize_callback' => 'sophia_after_dark_sanitize_select',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_section_slider_cat', $wp_customize->add_control(
'sophia_after_dark_section_slider_cat',
array( array(
'type' => 'select', 'type' => 'select',
'label' => esc_html__( 'Slider category', 'sophia-after-dark' ), 'label' => esc_html__( 'Slider category', 'sophia-after-dark' ),
'description' => esc_html__( 'Choose default post category', 'sophia-after-dark' ), 'description' => esc_html__( 'Choose default post category', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_slider', 'section' => 'sophia_after_dark_section_slider',
'default' => '', 'default' => '',
'priority' => 30, 'priority' => 30,
'choices' => sophia_after_dark_select_categories_list(), 'choices' => sophia_after_dark_select_categories_list(),
'active_callback' => 'sophia_after_dark_section_slider_option_active_callback', 'active_callback' => 'sophia_after_dark_section_slider_option_active_callback',
) )
); );
/** /**
* Image field for background image in slider section * Image field for background image in slider section
*/ */
$wp_customize->add_setting( 'sophia_after_dark_slider_bg_image', $wp_customize->add_setting(
'sophia_after_dark_slider_bg_image',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => '', 'default' => '',
'sanitize_callback' => 'esc_url_raw', 'sanitize_callback' => 'esc_url_raw',
) )
); );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_slider_bg_image', new WP_Customize_Image_Control(
$wp_customize,
'sophia_after_dark_slider_bg_image',
array( array(
'label' => __( 'Slider Section Background Image', 'sophia-after-dark' ), 'label' => __( 'Slider Section Background Image', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_slider', 'section' => 'sophia_after_dark_section_slider',
'settings' => 'sophia_after_dark_slider_bg_image', 'settings' => 'sophia_after_dark_slider_bg_image',
'priority' => 40, 'priority' => 40,
'active_callback' => 'sophia_after_dark_section_slider_option_active_callback' 'active_callback' => 'sophia_after_dark_section_slider_option_active_callback',
) )
) )
); );
@@ -102,36 +108,39 @@ function sophia_after_dark_customize_slider_panels_sections_register( $wp_custom
/** /**
* Featured Slider Settings * Featured Slider Settings
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_top_featured_post', $wp_customize->add_section(
'sophia_after_dark_section_top_featured_post',
array( array(
'priority' => 20, 'priority' => 20,
'panel' => 'sophia_after_dark_front_section_panel', 'panel' => 'sophia_after_dark_front_section_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => esc_html__( 'Featured Posts Settings', 'sophia-after-dark' ), 'title' => esc_html__( 'Featured Posts Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Toggle field for featured slider option * Toggle field for featured slider option
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_section_top_featured_posts_option', $wp_customize->add_setting(
'sophia_after_dark_section_top_featured_posts_option',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_section_top_featured_posts_option', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_section_top_featured_posts_option',
array( array(
'label' => esc_html__( 'Enable Featured Posts Section', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Featured Posts Section', 'sophia-after-dark' ),
'description' => 'This section is displayed after the slider content at the right side minimizing the slider width.', 'description' => 'This section is displayed after the slider content at the right side minimizing the slider width.',
'section' => 'sophia_after_dark_section_top_featured_post', 'section' => 'sophia_after_dark_section_top_featured_post',
'settings' => 'sophia_after_dark_section_top_featured_posts_option', 'settings' => 'sophia_after_dark_section_top_featured_posts_option',
'priority' => 5, 'priority' => 5,
) )
) )
); );
@@ -139,46 +148,50 @@ function sophia_after_dark_customize_slider_panels_sections_register( $wp_custom
/** /**
* Text field for Featured Posts Title * Text field for Featured Posts Title
*/ */
$wp_customize->add_setting( 'sophia_after_dark_top_featured_posts_title', $wp_customize->add_setting(
'sophia_after_dark_top_featured_posts_title',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( 'Featured News', 'sophia-after-dark' ), 'default' => esc_html__( 'Featured News', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_top_featured_posts_title', $wp_customize->add_control(
'sophia_after_dark_top_featured_posts_title',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Featured News', 'sophia-after-dark' ), 'label' => esc_html__( 'Featured News', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_featured_post', 'section' => 'sophia_after_dark_section_top_featured_post',
'priority' => 10, 'priority' => 10,
'active_callback' => 'sophia_after_dark_section_top_featured_posts_option_active_callback', 'active_callback' => 'sophia_after_dark_section_top_featured_posts_option_active_callback',
) )
); );
/** /**
* Select field for featured posts type. * Select field for featured posts type.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_top_featured_post_order', $wp_customize->add_setting(
'sophia_after_dark_top_featured_post_order',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => 'default', 'default' => 'default',
'sanitize_callback' => 'sophia_after_dark_sanitize_select', 'sanitize_callback' => 'sophia_after_dark_sanitize_select',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_top_featured_post_order', $wp_customize->add_control(
'sophia_after_dark_top_featured_post_order',
array( array(
'type' => 'select', 'type' => 'select',
'label' => esc_html__( 'Featured Post Order', 'sophia-after-dark' ), 'label' => esc_html__( 'Featured Post Order', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_featured_post', 'section' => 'sophia_after_dark_section_top_featured_post',
'priority' => 15, 'priority' => 15,
'choices' => array( 'choices' => array(
'default' => __( 'Latest Posts', 'sophia-after-dark' ), 'default' => __( 'Latest Posts', 'sophia-after-dark' ),
'random' => __( 'Random Posts', 'sophia-after-dark' ), 'random' => __( 'Random Posts', 'sophia-after-dark' ),
), ),
'active_callback' => 'sophia_after_dark_section_top_featured_posts_option_active_callback', 'active_callback' => 'sophia_after_dark_section_top_featured_posts_option_active_callback',
) )
); );
} }

View File

@@ -9,116 +9,129 @@
add_action( 'customize_register', 'sophia_after_dark_customize_general_panels_sections_register' ); add_action( 'customize_register', 'sophia_after_dark_customize_general_panels_sections_register' );
/** /**
* Add panels in the theme customizer * Add panels in the theme customizer
*
*/ */
function sophia_after_dark_customize_general_panels_sections_register( $wp_customize ) { function sophia_after_dark_customize_general_panels_sections_register( $wp_customize ) {
/*------------------------------------------- Site Settings Section -----------------------------------------------*/ /*------------------------------------------- Site Settings Section -----------------------------------------------*/
/** /**
* Site Settings Section * Site Settings Section
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_site', $wp_customize->add_section(
'sophia_after_dark_section_site',
array( array(
'priority' => 40, 'priority' => 40,
'panel' => 'sophia_after_dark_general_panel', 'panel' => 'sophia_after_dark_general_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Site Settings', 'sophia-after-dark' ) 'title' => __( 'Site Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Toggle field for Enable/Disable wow animation. * Toggle field for Enable/Disable wow animation.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_wow_animation', $wp_customize->add_setting(
'sophia_after_dark_enable_wow_animation',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_wow_animation', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_wow_animation',
array( array(
'label' => __( 'Enable Wow Animation', 'sophia-after-dark' ), 'label' => __( 'Enable Wow Animation', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_site', 'section' => 'sophia_after_dark_section_site',
'settings' => 'sophia_after_dark_enable_wow_animation', 'settings' => 'sophia_after_dark_enable_wow_animation',
'priority' => 10, 'priority' => 10,
) )
) )
); );
$wp_customize->add_control(new WP_Customize_Image_control( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_home_og_image', array( new WP_Customize_Image_control(
'label' => __('Home Page Open Graph Image', 'sophia_after_dark'), $wp_customize,
'section' => 'sophia_after_dark_section_site', 'sophia_after_dark_home_og_image',
'settings' => 'sophia_after_dark_home_og_image', array(
'priority' => 15, 'label' => __( 'Home Page Open Graph Image', 'sophia_after_dark' ),
'section' => 'sophia_after_dark_section_site',
'settings' => 'sophia_after_dark_home_og_image',
'priority' => 15,
)
) )
)
); );
$users = get_users(); $users = get_users();
$user_choices = array(); $user_choices = array();
foreach ($users as $user) { foreach ( $users as $user ) {
$user_choices[$user->ID] = $user->display_name; $user_choices[ $user->ID ] = $user->display_name;
} }
$wp_customize->add_control('sophia_after_dark_home_og_user', array( $wp_customize->add_control(
'label' => __('Select User for Open Graph Tags', 'sophia_after_dark'), 'sophia_after_dark_home_og_user',
'section' => 'sophia_after_dark_section_site', array(
'settings' => 'sophia_after_dark_home_og_user', 'label' => __( 'Select User for Open Graph Tags', 'sophia_after_dark' ),
'type' => 'select', 'section' => 'sophia_after_dark_section_site',
'choices' => $user_choices, 'settings' => 'sophia_after_dark_home_og_user',
'priority' => 20, 'type' => 'select',
) 'choices' => $user_choices,
'priority' => 20,
)
); );
/** /**
* Radio image field for Archive Sidebar * Radio image field for Archive Sidebar
* *
* @since 1.0.0 * @since 1.0.0
*/ */
$wp_customize->add_setting( 'sophia_after_dark_site_layout', $wp_customize->add_setting(
'sophia_after_dark_site_layout',
array( array(
'default' => 'site-layout--wide', 'default' => 'site-layout--wide',
'sanitize_callback' => 'sanitize_key', 'sanitize_callback' => 'sanitize_key',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Radio_Image( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_site_layout', new Sophia_After_Dark_Control_Radio_Image(
$wp_customize,
'sophia_after_dark_site_layout',
array( array(
'label' => __( 'Site Layout', 'sophia-after-dark' ), 'label' => __( 'Site Layout', 'sophia-after-dark' ),
'description' => __( 'Choose site layout from available layouts', 'sophia-after-dark' ), 'description' => __( 'Choose site layout from available layouts', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_site', 'section' => 'sophia_after_dark_section_site',
'settings' => 'sophia_after_dark_site_layout', 'settings' => 'sophia_after_dark_site_layout',
'priority' => 25, 'priority' => 25,
'choices' => array( 'choices' => array(
'site-layout--wide' => get_template_directory_uri() . '/assets/images/full-width.png', 'site-layout--wide' => get_template_directory_uri() . '/assets/images/full-width.png',
'site-layout--boxed' => get_template_directory_uri() . '/assets/images/boxed-layout.png' 'site-layout--boxed' => get_template_directory_uri() . '/assets/images/boxed-layout.png',
), ),
) )
) )
); );
/** /**
* Toggle field for block based widget editor. * Toggle field for block based widget editor.
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_widgets_editor', $wp_customize->add_setting(
'sophia_after_dark_enable_widgets_editor',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => false, 'default' => false,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_widgets_editor', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_widgets_editor',
array( array(
'label' => __( 'Enable Widgets Editor', 'sophia-after-dark' ), 'label' => __( 'Enable Widgets Editor', 'sophia-after-dark' ),
'description' => __( 'Enable/disable Block-based Widgets Editor(since WordPress 5.8).', 'sophia-after-dark' ), 'description' => __( 'Enable/disable Block-based Widgets Editor(since WordPress 5.8).', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_site', 'section' => 'sophia_after_dark_section_site',
'settings' => 'sophia_after_dark_enable_widgets_editor', 'settings' => 'sophia_after_dark_enable_widgets_editor',
'priority' => 25, 'priority' => 25,
) )
) )
); );

View File

@@ -9,7 +9,6 @@
add_action( 'customize_register', 'sophia_after_dark_customize_header_panels_sections_register' ); add_action( 'customize_register', 'sophia_after_dark_customize_header_panels_sections_register' );
/** /**
* Add panels in the theme customizer * Add panels in the theme customizer
*
*/ */
function sophia_after_dark_customize_header_panels_sections_register( $wp_customize ) { function sophia_after_dark_customize_header_panels_sections_register( $wp_customize ) {
@@ -17,228 +16,241 @@ function sophia_after_dark_customize_header_panels_sections_register( $wp_custom
/** /**
* Top Header Section * Top Header Section
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_top_header', $wp_customize->add_section(
'sophia_after_dark_section_top_header',
array( array(
'priority' => 10, 'priority' => 10,
'panel' => 'sophia_after_dark_header_panel', 'panel' => 'sophia_after_dark_header_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Top Header Settings', 'sophia-after-dark' ) 'title' => __( 'Top Header Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Toggle field for Enable/Disable Top Header section * Toggle field for Enable/Disable Top Header section
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_top_header', $wp_customize->add_setting(
'sophia_after_dark_enable_top_header',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_top_header', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_top_header',
array( array(
'label' => __( 'Enable Top Header', 'sophia-after-dark' ), 'label' => __( 'Enable Top Header', 'sophia-after-dark' ),
'description' => esc_html__( 'Show/Hide top header section.', 'sophia-after-dark' ), 'description' => esc_html__( 'Show/Hide top header section.', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'settings' => 'sophia_after_dark_enable_top_header', 'settings' => 'sophia_after_dark_enable_top_header',
'priority' => 10, 'priority' => 10,
) )
) )
); );
/** /**
* Toggle field for Enable/Disable trending section. * Toggle field for Enable/Disable trending section.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_trending', $wp_customize->add_setting(
'sophia_after_dark_enable_trending',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => false, 'default' => false,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_trending', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_trending',
array( array(
'label' => esc_html__( 'Enable Trending Section', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Trending Section', 'sophia-after-dark' ),
'description' => esc_html__( 'Trending section shows the popular tags.', 'sophia-after-dark' ), 'description' => esc_html__( 'Trending section shows the popular tags.', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'settings' => 'sophia_after_dark_enable_trending', 'settings' => 'sophia_after_dark_enable_trending',
'priority' => 10, 'priority' => 10,
'active_callback' => 'sophia_after_dark_enable_top_header_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_active_callback',
) )
) )
); );
/** /**
* checkox for before icon in tags. * checkox for before icon in tags.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_trending_tag_before_icon', $wp_customize->add_setting(
'sophia_after_dark_enable_trending_tag_before_icon',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_enable_trending_tag_before_icon', $wp_customize->add_control(
'sophia_after_dark_enable_trending_tag_before_icon',
array( array(
'type' => 'checkbox', 'type' => 'checkbox',
'label' => esc_html__( 'Add Icon Before Tag', 'sophia-after-dark' ), 'label' => esc_html__( 'Add Icon Before Tag', 'sophia-after-dark' ),
'description' => esc_html__( 'Show/Hide Hash Icon before tag.', 'sophia-after-dark' ), 'description' => esc_html__( 'Show/Hide Hash Icon before tag.', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'priority' => 20, 'priority' => 20,
'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback',
) )
); );
/** /**
* Text field for trending label. * Text field for trending label.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_trending_label', $wp_customize->add_setting(
'sophia_after_dark_trending_label',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( 'Trending Now', 'sophia-after-dark' ), 'default' => esc_html__( 'Trending Now', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_trending_label', $wp_customize->add_control(
'sophia_after_dark_trending_label',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Trending Label', 'sophia-after-dark' ), 'label' => esc_html__( 'Trending Label', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'priority' => 25, 'priority' => 25,
'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback',
) )
); );
/** /**
* Select field of trending tags orderby. * Select field of trending tags orderby.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_trending_tags_orderby', $wp_customize->add_setting(
'sophia_after_dark_trending_tags_orderby',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => '', 'default' => '',
'sanitize_callback' => 'sophia_after_dark_sanitize_select', 'sanitize_callback' => 'sophia_after_dark_sanitize_select',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_trending_tags_orderby', $wp_customize->add_control(
'sophia_after_dark_trending_tags_orderby',
array( array(
'type' => 'select', 'type' => 'select',
'label' => esc_html__( 'Tags Orderby', 'sophia-after-dark' ), 'label' => esc_html__( 'Tags Orderby', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'default' => '', 'default' => '',
'priority' => 30, 'priority' => 30,
'choices' => array( 'choices' => array(
'' => esc_html__( 'Default', 'sophia-after-dark' ), '' => esc_html__( 'Default', 'sophia-after-dark' ),
'count' => esc_html__( 'Count', 'sophia-after-dark' ), 'count' => esc_html__( 'Count', 'sophia-after-dark' ),
), ),
'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback',
) )
); );
/** /**
* Number field of trending tags count. * Number field of trending tags count.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_trending_tags_count', $wp_customize->add_setting(
'sophia_after_dark_trending_tags_count',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => '5', 'default' => '5',
'sanitize_callback' => 'absint', 'sanitize_callback' => 'absint',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_trending_tags_count', $wp_customize->add_control(
'sophia_after_dark_trending_tags_count',
array( array(
'type' => 'number', 'type' => 'number',
'label' => esc_html__( 'Tags Count', 'sophia-after-dark' ), 'label' => esc_html__( 'Tags Count', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'priority' => 35, 'priority' => 35,
'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_trending_active_callback',
) )
); );
/** /**
* Toggle field for Enable/Disable live now button. * Toggle field for Enable/Disable live now button.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_live_now', $wp_customize->add_setting(
'sophia_after_dark_enable_live_now',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => false, 'default' => false,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_live_now', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_live_now',
array( array(
'label' => esc_html__( 'Enable Live Now Button', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Live Now Button', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'settings' => 'sophia_after_dark_enable_live_now', 'settings' => 'sophia_after_dark_enable_live_now',
'priority' => 40, 'priority' => 40,
'active_callback' => 'sophia_after_dark_enable_top_header_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_active_callback',
) )
) )
); );
/** /**
* Text field for live now button label. * Text field for live now button label.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_live_now_label', $wp_customize->add_setting(
'sophia_after_dark_live_now_label',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => esc_html__( 'Live Now', 'sophia-after-dark' ), 'default' => esc_html__( 'Live Now', 'sophia-after-dark' ),
'sanitize_callback' => 'sanitize_text_field' 'sanitize_callback' => 'sanitize_text_field',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_live_now_label', $wp_customize->add_control(
'sophia_after_dark_live_now_label',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Button Label', 'sophia-after-dark' ), 'label' => esc_html__( 'Button Label', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'settings' => 'sophia_after_dark_live_now_label', 'settings' => 'sophia_after_dark_live_now_label',
'priority' => 45, 'priority' => 45,
'active_callback' => 'sophia_after_dark_enable_top_header_live_now_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_live_now_active_callback',
) )
); );
/** /**
* Text field for live now button link. * Text field for live now button link.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_live_now_link', $wp_customize->add_setting(
'sophia_after_dark_live_now_link',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw' 'sanitize_callback' => 'esc_url_raw',
) )
); );
$wp_customize->add_control( 'sophia_after_dark_live_now_link', $wp_customize->add_control(
'sophia_after_dark_live_now_link',
array( array(
'type' => 'text', 'type' => 'text',
'label' => esc_html__( 'Button Link', 'sophia-after-dark' ), 'label' => esc_html__( 'Button Link', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_top_header', 'section' => 'sophia_after_dark_section_top_header',
'settings' => 'sophia_after_dark_live_now_link', 'settings' => 'sophia_after_dark_live_now_link',
'priority' => 50, 'priority' => 50,
'active_callback' => 'sophia_after_dark_enable_top_header_live_now_active_callback', 'active_callback' => 'sophia_after_dark_enable_top_header_live_now_active_callback',
'input_attrs' => array( 'input_attrs' => array(
'placeholder' => "https://www.youtube.com/channel/UCnGp3UHMB4DH8W_KmSmrCEw" 'placeholder' => 'https://www.youtube.com/channel/UCnGp3UHMB4DH8W_KmSmrCEw',
) ),
) )
); );
@@ -246,81 +258,88 @@ function sophia_after_dark_customize_header_panels_sections_register( $wp_custom
/** /**
* Header Extra Options * Header Extra Options
*/ */
$wp_customize->add_section( 'sophia_after_dark_section_header_extra', $wp_customize->add_section(
'sophia_after_dark_section_header_extra',
array( array(
'priority' => 30, 'priority' => 30,
'panel' => 'sophia_after_dark_header_panel', 'panel' => 'sophia_after_dark_header_panel',
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Extra Options', 'sophia-after-dark' ) 'title' => __( 'Extra Options', 'sophia-after-dark' ),
) )
); );
/** /**
* Toggle field for Enable/Disable sticky menu. * Toggle field for Enable/Disable sticky menu.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_sticky_menu', $wp_customize->add_setting(
'sophia_after_dark_enable_sticky_menu',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_sticky_menu', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_sticky_menu',
array( array(
'label' => esc_html__( 'Enable Sticky Menu', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Sticky Menu', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_header_extra', 'section' => 'sophia_after_dark_section_header_extra',
'settings' => 'sophia_after_dark_enable_sticky_menu', 'settings' => 'sophia_after_dark_enable_sticky_menu',
'priority' => 5, 'priority' => 5,
) )
) )
); );
/** /**
* Toggle field for Enable/Disable social icons. * Toggle field for Enable/Disable social icons.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_header_social_icons', $wp_customize->add_setting(
'sophia_after_dark_enable_header_social_icons',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => false, 'default' => false,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_header_social_icons', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_header_social_icons',
array( array(
'label' => esc_html__( 'Enable Social Icons', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Social Icons', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_header_extra', 'section' => 'sophia_after_dark_section_header_extra',
'settings' => 'sophia_after_dark_enable_header_social_icons', 'settings' => 'sophia_after_dark_enable_header_social_icons',
'priority' => 10, 'priority' => 10,
) )
) )
); );
/** /**
* Toggle field for Enable/Disable search icon. * Toggle field for Enable/Disable search icon.
*
*/ */
$wp_customize->add_setting( 'sophia_after_dark_enable_search_icon', $wp_customize->add_setting(
'sophia_after_dark_enable_search_icon',
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => true, 'default' => true,
'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox' 'sanitize_callback' => 'sophia_after_dark_sanitize_checkbox',
) )
); );
$wp_customize->add_control( new Sophia_After_Dark_Control_Toggle( $wp_customize->add_control(
$wp_customize, 'sophia_after_dark_enable_search_icon', new Sophia_After_Dark_Control_Toggle(
$wp_customize,
'sophia_after_dark_enable_search_icon',
array( array(
'label' => esc_html__( 'Enable Search Icon', 'sophia-after-dark' ), 'label' => esc_html__( 'Enable Search Icon', 'sophia-after-dark' ),
'section' => 'sophia_after_dark_section_header_extra', 'section' => 'sophia_after_dark_section_header_extra',
'settings' => 'sophia_after_dark_enable_search_icon', 'settings' => 'sophia_after_dark_enable_search_icon',
'priority' => 15, 'priority' => 15,
) )
) )
); );

View File

@@ -9,78 +9,83 @@ add_action( 'customize_register', 'sophia_after_dark_customize_panels_register'
/** /**
* Add panels in the theme customizer * Add panels in the theme customizer
*
*/ */
function sophia_after_dark_customize_panels_register( $wp_customize ) { function sophia_after_dark_customize_panels_register( $wp_customize ) {
/** /**
* General Settings Panel * General Settings Panel
*/ */
$wp_customize->add_panel( 'sophia_after_dark_general_panel', $wp_customize->add_panel(
'sophia_after_dark_general_panel',
array( array(
'priority' => 10, 'priority' => 10,
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'General Settings', 'sophia-after-dark' ), 'title' => __( 'General Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Header Settings Panel * Header Settings Panel
*/ */
$wp_customize->add_panel( 'sophia_after_dark_header_panel', $wp_customize->add_panel(
'sophia_after_dark_header_panel',
array( array(
'priority' => 15, 'priority' => 15,
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Header Settings', 'sophia-after-dark' ), 'title' => __( 'Header Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Front Settings Panel * Front Settings Panel
*/ */
$wp_customize->add_panel( 'sophia_after_dark_front_section_panel', $wp_customize->add_panel(
'sophia_after_dark_front_section_panel',
array( array(
'priority' => 20, 'priority' => 20,
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Front Sections', 'sophia-after-dark' ), 'title' => __( 'Front Sections', 'sophia-after-dark' ),
) )
); );
/** /**
* Design Settings Panel * Design Settings Panel
*/ */
$wp_customize->add_panel( 'sophia_after_dark_design_panel', $wp_customize->add_panel(
'sophia_after_dark_design_panel',
array( array(
'priority' => 35, 'priority' => 35,
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Design Settings', 'sophia-after-dark' ), 'title' => __( 'Design Settings', 'sophia-after-dark' ),
) )
); );
/** /**
* Additional Features Panel * Additional Features Panel
*/ */
$wp_customize->add_panel( 'sophia_after_dark_additional_panel', $wp_customize->add_panel(
'sophia_after_dark_additional_panel',
array( array(
'priority' => 40, 'priority' => 40,
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Additional Features', 'sophia-after-dark' ), 'title' => __( 'Additional Features', 'sophia-after-dark' ),
) )
); );
/** /**
* Footer Settings Panel * Footer Settings Panel
*/ */
$wp_customize->add_panel( 'sophia_after_dark_footer_panel', $wp_customize->add_panel(
'sophia_after_dark_footer_panel',
array( array(
'priority' => 45, 'priority' => 45,
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'theme_supports' => '', 'theme_supports' => '',
'title' => __( 'Footer Settings', 'sophia-after-dark' ), 'title' => __( 'Footer Settings', 'sophia-after-dark' ),
) )
); );
} }

View File

@@ -16,24 +16,45 @@ function sophia_after_dark_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_section( 'title_tagline' )->panel = 'sophia_after_dark_general_panel'; $wp_customize->get_section( 'title_tagline' )->panel = 'sophia_after_dark_general_panel';
$wp_customize->get_section( 'title_tagline' )->priority = '5'; $wp_customize->get_section( 'background_image' )->panel = 'sophia_after_dark_general_panel'; $wp_customize->get_section( 'title_tagline' )->priority = '5';
$wp_customize->get_section( 'background_image' )->priority = '15'; $wp_customize->get_section( 'background_image' )->panel = 'sophia_after_dark_general_panel';
$wp_customize->get_section( 'static_front_page' )->panel = 'sophia_after_dark_general_panel'; $wp_customize->get_section( 'background_image' )->priority = '15';
$wp_customize->get_section( 'static_front_page' )->priority = '20'; $wp_customize->get_section( 'static_front_page' )->panel = 'sophia_after_dark_general_panel';
$wp_customize->get_section( 'header_image' )->panel = 'sophia_after_dark_header_panel'; $wp_customize->get_section( 'static_front_page' )->priority = '20';
$wp_customize->get_section( 'header_image' )->priority = '5'; $wp_customize->get_section( 'header_image' )->panel = 'sophia_after_dark_header_panel';
$wp_customize->get_section( 'header_image' )->description = __( 'Header Image for only Innerpages', 'sophia-after-dark' ); $wp_customize->get_section( 'header_image' )->priority = '5';
$wp_customize->add_setting('sophia_after_dark_home_og_image', array('default' => '','sanitize_callback' => 'esc_url_raw','type' => 'option',)); $wp_customize->get_section( 'header_image' )->description = __( 'Header Image for only Innerpages', 'sophia-after-dark' );
$wp_customize->add_setting('sophia_after_dark_home_og_user', array('default' => 1,'sanitize_callback' => 'absint','type' => 'option',)); $wp_customize->add_setting(
'sophia_after_dark_home_og_image',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
'type' => 'option',
)
);
$wp_customize->add_setting(
'sophia_after_dark_home_og_user',
array(
'default' => 1,
'sanitize_callback' => 'absint',
'type' => 'option',
)
);
if ( isset( $wp_customize->selective_refresh ) ) { if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array( $wp_customize->selective_refresh->add_partial(
'selector' => '.site-title a', 'blogname',
'render_callback' => 'sophia_after_dark_customize_partial_blogname', array(
) ); 'selector' => '.site-title a',
$wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'render_callback' => 'sophia_after_dark_customize_partial_blogname',
'selector' => '.site-description', )
'render_callback' => 'sophia_after_dark_customize_partial_blogdescription', );
) ); $wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'render_callback' => 'sophia_after_dark_customize_partial_blogdescription',
)
);
} }
/** /**
@@ -87,7 +108,7 @@ add_action( 'customize_controls_enqueue_scripts', 'sophia_after_dark_customize_b
/** /**
* Add Kirki required file for custom fields * Add Kirki required file for custom fields
*/ */
#require get_template_directory() . '/inc/customizer/sad-customizer-additional-open-graph.php'; // require get_template_directory() . '/inc/customizer/sad-customizer-additional-open-graph.php';
require get_template_directory() . '/inc/customizer/sad-customizer-custom-classes.php'; require get_template_directory() . '/inc/customizer/sad-customizer-custom-classes.php';
require get_template_directory() . '/inc/customizer/sad-customizer-panels.php'; require get_template_directory() . '/inc/customizer/sad-customizer-panels.php';

View File

@@ -8,7 +8,7 @@
if ( ! function_exists( 'sophia_after_dark_sanitize_checkbox' ) ) : if ( ! function_exists( 'sophia_after_dark_sanitize_checkbox' ) ) :
/** /**
* Sanitize checkbox. * Sanitize checkbox.
* *
* @since 1.0.0 * @since 1.0.0

View File

@@ -24,35 +24,35 @@ if ( ! function_exists( 'sophia_after_dark_site_branding' ) ) :
* function to display site branding * function to display site branding
*/ */
function sophia_after_dark_site_branding() { function sophia_after_dark_site_branding() {
?> ?>
<div class="logo-ads-wrap"> <div class="logo-ads-wrap">
<div class="sad-container"> <div class="sad-container">
<div class="site-branding"> <div class="site-branding">
<?php <?php
the_custom_logo(); the_custom_logo();
if ( is_front_page() || is_home() ) : if ( is_front_page() || is_home() ) :
?> ?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?> <?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php <?php
endif; endif;
$sophia_after_dark_description = get_bloginfo( 'description', 'display' ); $sophia_after_dark_description = get_bloginfo( 'description', 'display' );
if ( $sophia_after_dark_description || is_customize_preview() ) : if ( $sophia_after_dark_description || is_customize_preview() ) :
?> ?>
<p class="site-description"><?php echo $sophia_after_dark_description; /* WPCS: xss ok. */ ?></p> <p class="site-description"><?php echo $sophia_after_dark_description; /* WPCS: xss ok. */ ?></p>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="header-widget-wrapper"> <div class="header-widget-wrapper">
<?php <?php
if ( is_active_sidebar( 'header-ads-section' ) ) { if ( is_active_sidebar( 'header-ads-section' ) ) {
dynamic_sidebar( 'header-ads-section' ); dynamic_sidebar( 'header-ads-section' );
} }
?> ?>
</div> </div>
</div> </div>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -76,19 +76,21 @@ if ( ! function_exists( 'sophia_after_dark_header_main_menu' ) ) :
*/ */
function sophia_after_dark_header_main_menu() { function sophia_after_dark_header_main_menu() {
$sophia_after_dark_menu_toggle_text = apply_filters( 'sophia_after_dark_menu_toggle_text', __( 'Menu', 'sophia-after-dark' ) ); $sophia_after_dark_menu_toggle_text = apply_filters( 'sophia_after_dark_menu_toggle_text', __( 'Menu', 'sophia-after-dark' ) );
?> ?>
<div class="sad-header-menu-wrap"> <div class="sad-header-menu-wrap">
<div class="menu-toggle"><a href="javascript:void(0)"><i class="fa fa-navicon"></i><?php echo esc_html( $sophia_after_dark_menu_toggle_text ); ?></a></div> <div class="menu-toggle"><a href="javascript:void(0)"><i class="fa fa-navicon"></i><?php echo esc_html( $sophia_after_dark_menu_toggle_text ); ?></a></div>
<nav itemscope id="site-navigation" class="main-navigation"> <nav itemscope id="site-navigation" class="main-navigation">
<?php <?php
wp_nav_menu( array( wp_nav_menu(
'theme_location' => 'primary_menu', array(
'menu_id' => 'primary-menu', 'theme_location' => 'primary_menu',
) ); 'menu_id' => 'primary-menu',
)
);
?> ?>
</nav> </nav>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -115,12 +117,12 @@ if ( ! function_exists( 'sophia_after_dark_menu_social_icons' ) ) :
return; return;
} }
$sophia_after_dark_menu_social_icons_label = apply_filters( 'sophia_after_dark_menu_social_icons_label', __( 'Follow Us: ', 'sophia-after-dark' ) ); $sophia_after_dark_menu_social_icons_label = apply_filters( 'sophia_after_dark_menu_social_icons_label', __( 'Follow Us: ', 'sophia-after-dark' ) );
?> ?>
<div class="sad-social-wrapper"> <div class="sad-social-wrapper">
<span class="sad-follow-title"><?php echo esc_html( $sophia_after_dark_menu_social_icons_label ); ?></span> <span class="sad-follow-title"><?php echo esc_html( $sophia_after_dark_menu_social_icons_label ); ?></span>
<?php sophia_after_dark_social_media_content(); ?> <?php sophia_after_dark_social_media_content(); ?>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -136,7 +138,7 @@ if ( ! function_exists( 'sophia_after_dark_menu_search_icon' ) ) :
return; return;
} }
$sophia_after_dark_menu_search_icon_lable = apply_filters( 'sophia_after_dark_menu_search_icon_lable', __( 'Search', 'sophia-after-dark' ) ); $sophia_after_dark_menu_search_icon_lable = apply_filters( 'sophia_after_dark_menu_search_icon_lable', __( 'Search', 'sophia-after-dark' ) );
?> ?>
<div class="sad-menu-search"> <div class="sad-menu-search">
<div class="sad-search-icon"><a href="javascript:void(0)"><?php echo esc_html( $sophia_after_dark_menu_search_icon_lable ); ?><i class="fa fa-search"></i></a></div> <div class="sad-search-icon"><a href="javascript:void(0)"><?php echo esc_html( $sophia_after_dark_menu_search_icon_lable ); ?><i class="fa fa-search"></i></a></div>
<div class="sad-form-wrap"> <div class="sad-form-wrap">
@@ -146,7 +148,7 @@ if ( ! function_exists( 'sophia_after_dark_menu_search_icon' ) ) :
<div class="sad-form-close"><a href="javascript:void(0)"><i class="fa fa-close"></i></a></div> <div class="sad-form-close"><a href="javascript:void(0)"><i class="fa fa-close"></i></a></div>
</div> </div>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -207,34 +209,39 @@ if ( ! function_exists( 'sophia_after_dark_header_categories_lists_content' ) )
* function to display categories lists * function to display categories lists
*/ */
function sophia_after_dark_header_categories_lists_content() { function sophia_after_dark_header_categories_lists_content() {
$get_categories = get_categories( array( 'orderby' => 'name', 'order' => 'ASC' ) ); $get_categories = get_categories(
?> array(
'orderby' => 'name',
'order' => 'ASC',
)
);
?>
<div class="sad-header-cat-list-wrapper"> <div class="sad-header-cat-list-wrapper">
<ul class="sticky-header-sidebar-menu sad-slide-cat-lists"> <ul class="sticky-header-sidebar-menu sad-slide-cat-lists">
<?php <?php
$count = 1; $count = 1;
$cat_list_items = apply_filters( 'sophia_after_dark_menu_cat_list_items', 5 ); $cat_list_items = apply_filters( 'sophia_after_dark_menu_cat_list_items', 5 );
foreach ( $get_categories as $category ) { foreach ( $get_categories as $category ) {
$cat_link = get_category_link( $category->term_id ); $cat_link = get_category_link( $category->term_id );
$cat_name = $category->name; $cat_name = $category->name;
$cat_count = $category->count; $cat_count = $category->count;
if ( $count <= $cat_list_items ) { if ( $count <= $cat_list_items ) {
?> ?>
<li class="cat-item"> <li class="cat-item">
<a href="<?php echo esc_url( $cat_link ); ?>"> <a href="<?php echo esc_url( $cat_link ); ?>">
<?php <?php
echo esc_html( $cat_name ); echo esc_html( $cat_name );
echo '<span>'. esc_html( $cat_count ) .'</span>'; echo '<span>' . esc_html( $cat_count ) . '</span>';
?> ?>
</a> </a>
</li> </li>
<?php <?php
}
} }
}
?> ?>
</ul> </ul>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -247,16 +254,16 @@ if ( ! function_exists( 'sophia_after_dark_header_author_box_content' ) ) :
*/ */
function sophia_after_dark_header_author_box_content() { function sophia_after_dark_header_author_box_content() {
$sophia_after_dark_user_id = apply_filters( 'sophia_after_dark_header_user_id', 1 ); $sophia_after_dark_user_id = apply_filters( 'sophia_after_dark_header_user_id', 1 );
?> ?>
<div itemscope itemtype="http://schema.org/Person" class="sticky-header-sidebar-author author-bio-wrap"> <div itemscope itemtype="http://schema.org/Person" class="sticky-header-sidebar-author author-bio-wrap">
<div class="author-avatar"><?php echo get_avatar( $sophia_after_dark_user_id, '150' ); ?></div> <div class="author-avatar"><?php echo get_avatar( $sophia_after_dark_user_id, '150' ); ?></div>
<h3 itemprop="name" class="author-name"><?php echo esc_html( get_the_author_meta( 'nicename', $sophia_after_dark_user_id ) ); ?></h3> <h3 itemprop="name" class="author-name"><?php echo esc_html( get_the_author_meta( 'nicename', $sophia_after_dark_user_id ) ); ?></h3>
<div class="author-description"><?php echo wp_kses_post( wpautop( get_the_author_meta( 'description', $sophia_after_dark_user_id ) ) ); ?></div> <div class="author-description"><?php echo wp_kses_post( wpautop( get_the_author_meta( 'description', $sophia_after_dark_user_id ) ) ); ?></div>
<div class="author-social"> <div class="author-social">
<?php sophia_after_dark_social_media_content(); ?> <?php sophia_after_dark_social_media_content(); ?>
</div> </div>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -274,7 +281,7 @@ if ( ! function_exists( 'sophia_after_dark_scroll_top_content' ) ) :
*/ */
function sophia_after_dark_scroll_top_content() { function sophia_after_dark_scroll_top_content() {
$sophia_after_dark_scroll_top_text = apply_filters( 'sophia_after_dark_scroll_top_text', __( 'Back To Top', 'sophia-after-dark' ) ); $sophia_after_dark_scroll_top_text = apply_filters( 'sophia_after_dark_scroll_top_text', __( 'Back To Top', 'sophia-after-dark' ) );
echo '<div id="sad-scrollup" class="animated arrow-hide">'. esc_html( $sophia_after_dark_scroll_top_text ) .'</div>'; echo '<div id="sad-scrollup" class="animated arrow-hide">' . esc_html( $sophia_after_dark_scroll_top_text ) . '</div>';
} }
endif; endif;
@@ -288,15 +295,15 @@ if ( ! function_exists( 'sophia_after_dark_innerpage_header_start' ) ) :
function sophia_after_dark_innerpage_header_start() { function sophia_after_dark_innerpage_header_start() {
$inner_header_attribute = ''; $inner_header_attribute = '';
$inner_header_attribute = apply_filters( 'sophia_after_dark_inner_header_style_attribute', $inner_header_attribute ); $inner_header_attribute = apply_filters( 'sophia_after_dark_inner_header_style_attribute', $inner_header_attribute );
if ( !empty( $inner_header_attribute ) ) { if ( ! empty( $inner_header_attribute ) ) {
$header_class = 'has-bg-img'; $header_class = 'has-bg-img';
} else { } else {
$header_class = 'no-bg-img'; $header_class = 'no-bg-img';
} }
?> ?>
<div class="custom-header <?php echo esc_attr( $header_class ); ?>" <?php echo ( ! empty( $inner_header_attribute ) ) ? ' style="' . esc_attr( $inner_header_attribute ) . '" ' : ''; ?>> <div class="custom-header <?php echo esc_attr( $header_class ); ?>" <?php echo ( ! empty( $inner_header_attribute ) ) ? ' style="' . esc_attr( $inner_header_attribute ) . '" ' : ''; ?>>
<div class="sad-container"> <div class="sad-container">
<?php <?php
} }
endif; endif;
@@ -313,17 +320,17 @@ if ( ! function_exists( 'sophia_after_dark_innerpage_header_title' ) ) :
the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_title( '<h1 class="page-title">', '</h1>' );
the_archive_description( '<div class="taxonomy-description">', '</div>' ); the_archive_description( '<div class="taxonomy-description">', '</div>' );
} elseif ( is_search() ) { } elseif ( is_search() ) {
?> ?>
<h1 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', 'sophia-after-dark' ), '<span>' . get_search_query() . '</span>' ); ?></h1> <h1 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', 'sophia-after-dark' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
<?php <?php
} elseif ( is_404() ) { } elseif ( is_404() ) {
echo '<h1 class="entry-title">'. esc_html( 'Error 404', 'sophia-after-dark' ) .'</h1>'; echo '<h1 class="entry-title">' . esc_html( 'Error 404', 'sophia-after-dark' ) . '</h1>';
} elseif ( is_home() ) { } elseif ( is_home() ) {
$page_for_posts_id = get_option( 'page_for_posts' ); $page_for_posts_id = get_option( 'page_for_posts' );
$page_title = get_the_title( $page_for_posts_id ); $page_title = get_the_title( $page_for_posts_id );
?> ?>
<h1 class="entry-title"><?php echo esc_html( $page_title ); ?></h1> <h1 class="entry-title"><?php echo esc_html( $page_title ); ?></h1>
<?php <?php
} }
} }
@@ -339,18 +346,20 @@ if ( ! function_exists( 'sophia_after_dark_breadcrumb_content' ) ) :
if ( false === $sophia_after_dark_breadcrumb_option ) { if ( false === $sophia_after_dark_breadcrumb_option ) {
return; return;
} }
?> ?>
<nav id="breadcrumb" class="sad-breadcrumb"> <nav id="breadcrumb" class="sad-breadcrumb">
<?php <?php
breadcrumb_trail( array( breadcrumb_trail(
'container' => 'div', array(
'before' => '<div class="sad-container">', 'container' => 'div',
'after' => '</div>', 'before' => '<div class="sad-container">',
'show_browse' => false, 'after' => '</div>',
) ); 'show_browse' => false,
)
);
?> ?>
</nav> </nav>
<?php <?php
} }
endif; endif;
@@ -361,10 +370,10 @@ if ( ! function_exists( 'sophia_after_dark_innerpage_header_end' ) ) :
* function to manage ending div of section * function to manage ending div of section
*/ */
function sophia_after_dark_innerpage_header_end() { function sophia_after_dark_innerpage_header_end() {
?> ?>
</div> </div>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -383,7 +392,6 @@ if ( ! function_exists( 'sophia_after_dark_front_slider' ) ) :
/** /**
* Function displaying front slider section * Function displaying front slider section
*
*/ */
function sophia_after_dark_front_slider() { function sophia_after_dark_front_slider() {
$sophia_after_dark_section_slider_option = get_theme_mod( 'sophia_after_dark_section_slider_option', false ); $sophia_after_dark_section_slider_option = get_theme_mod( 'sophia_after_dark_section_slider_option', false );
@@ -396,31 +404,31 @@ if ( ! function_exists( 'sophia_after_dark_front_slider' ) ) :
} else { } else {
$slider_class = 'no-featured-slider full-width--slider'; $slider_class = 'no-featured-slider full-width--slider';
} }
?> ?>
<div class="front-slider-wrapper <?php echo esc_attr( $slider_class ); ?>"> <div class="front-slider-wrapper <?php echo esc_attr( $slider_class ); ?>">
<div class="sad-container"> <div class="sad-container">
<div class="front-slider-block"> <div class="front-slider-block">
<div class="front-slider cS-hidden"> <div class="front-slider cS-hidden">
<?php <?php
$slider_cat_slug = get_theme_mod( 'sophia_after_dark_section_slider_cat', '' ); $slider_cat_slug = get_theme_mod( 'sophia_after_dark_section_slider_cat', '' );
$slide_post_count = apply_filters( 'sophia_after_dark_slider_post_count', 3 ); $slide_post_count = apply_filters( 'sophia_after_dark_slider_post_count', 3 );
$slider_args = array( $slider_args = array(
'category_name' => esc_attr( $slider_cat_slug ), 'category_name' => esc_attr( $slider_cat_slug ),
'meta_key' => '_thumbnail_id', 'meta_key' => '_thumbnail_id',
'posts_per_page' => absint( $slide_post_count ) 'posts_per_page' => absint( $slide_post_count ),
); );
$slider_post_query = new WP_Query( $slider_args ); $slider_post_query = new WP_Query( $slider_args );
if ( $slider_post_query->have_posts() ) : if ( $slider_post_query->have_posts() ) :
while ( $slider_post_query-> have_posts() ) : while ( $slider_post_query->have_posts() ) :
$slider_post_query -> the_post(); $slider_post_query->the_post();
$post_id = get_the_ID(); $post_id = get_the_ID();
$image_url = get_the_post_thumbnail_url( $post_id, 'large' ); $image_url = get_the_post_thumbnail_url( $post_id, 'large' );
if ( ! empty( $image_url ) ) { if ( ! empty( $image_url ) ) {
$slider_style = 'style="background:url('. esc_url( $image_url ) .') no-repeat scroll center center; background-size:cover"'; $slider_style = 'style="background:url(' . esc_url( $image_url ) . ') no-repeat scroll center center; background-size:cover"';
} else { } else {
$slider_style = ''; $slider_style = '';
} }
?> ?>
<div class="slider-post-wrap" <?php echo $slider_style; ?>> <div class="slider-post-wrap" <?php echo $slider_style; ?>>
<div class="post-thumbnail"> <div class="post-thumbnail">
<a href="<?php the_permalink(); ?>"></a> <a href="<?php the_permalink(); ?>"></a>
@@ -432,68 +440,69 @@ if ( ! function_exists( 'sophia_after_dark_front_slider' ) ) :
sophia_after_dark_posted_on(); sophia_after_dark_posted_on();
sophia_after_dark_posted_by(); sophia_after_dark_posted_by();
?> ?>
</div> </div>
<?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?> <?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?>
</div> </div>
</div> </div>
<?php <?php
endwhile; endwhile;
endif; endif;
?> ?>
</div> </div>
</div> </div>
<?php <?php
if ( true == $sophia_after_dark_section_top_featured_posts_option ) { if ( true == $sophia_after_dark_section_top_featured_posts_option ) {
$sophia_after_dark_top_featured_posts_title = get_theme_mod( 'sophia_after_dark_top_featured_posts_title', __( 'Featured News', 'sophia-after-dark' ) ); $sophia_after_dark_top_featured_posts_title = get_theme_mod( 'sophia_after_dark_top_featured_posts_title', __( 'Featured News', 'sophia-after-dark' ) );
echo '<div class="top-featured-post-main-wrapper">'; echo '<div class="top-featured-post-main-wrapper">';
if ( ! empty( $sophia_after_dark_top_featured_posts_title ) ) { if ( ! empty( $sophia_after_dark_top_featured_posts_title ) ) {
echo '<div class="features-post-title">'.esc_html( $sophia_after_dark_top_featured_posts_title ).'</div>'; echo '<div class="features-post-title">' . esc_html( $sophia_after_dark_top_featured_posts_title ) . '</div>';
} }
$sophia_after_dark_top_featured_post_order = get_theme_mod( 'sophia_after_dark_top_featured_post_order', 'default' ); $sophia_after_dark_top_featured_post_order = get_theme_mod( 'sophia_after_dark_top_featured_post_order', 'default' );
$featured_posts_per_page = apply_filters( 'sophia_after_dark_featured_post_count', 5 ); $featured_posts_per_page = apply_filters( 'sophia_after_dark_featured_post_count', 5 );
$top_featured_post_args = array( $top_featured_post_args = array(
'post_type' => 'post', 'post_type' => 'post',
'posts_per_page' => absint( $featured_posts_per_page ), 'posts_per_page' => absint( $featured_posts_per_page ),
); );
if ( 'random' == $sophia_after_dark_top_featured_post_order ) { if ( 'random' == $sophia_after_dark_top_featured_post_order ) {
$top_featured_post_args['orderby'] = 'rand'; $top_featured_post_args['orderby'] = 'rand';
} }
$top_featured_post_query = new WP_Query( $top_featured_post_args ); $top_featured_post_query = new WP_Query( $top_featured_post_args );
if ( $top_featured_post_query -> have_posts() ) : if ( $top_featured_post_query->have_posts() ) :
echo '<div class="top-featured-post-wrap">'; echo '<div class="top-featured-post-wrap">';
$featured_post_count = 1; $featured_post_count = 1;
while ( $top_featured_post_query -> have_posts() ) : $top_featured_post_query -> the_post(); while ( $top_featured_post_query->have_posts() ) :
?> $top_featured_post_query->the_post();
?>
<div id="post-<?php the_ID(); ?>" class="sad-single-post-wrap sad-clearfix"> <div id="post-<?php the_ID(); ?>" class="sad-single-post-wrap sad-clearfix">
<div class="post-thumbnail"> <div class="post-thumbnail">
<span class="post-number"><?php echo absint( $featured_post_count ); ?></span> <span class="post-number"><?php echo absint( $featured_post_count ); ?></span>
<figure style="background: no-repeat center top url(<?php echo get_the_post_thumbnail_url(); ?>); background-size: cover; height: 100px;"> <figure style="background: no-repeat center top url(<?php echo get_the_post_thumbnail_url(); ?>); background-size: cover; height: 100px;">
</figure> </figure>
</div> </div>
<div class="sad-post-content"> <div class="sad-post-content">
<div class="entry-meta"> <div class="entry-meta">
<?php <?php
sophia_after_dark_posted_on(); sophia_after_dark_posted_on();
sophia_after_dark_posted_by(); sophia_after_dark_posted_by();
?> ?>
</div> </div>
<header class="entry-header"> <header class="entry-header">
<?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?> <?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?>
</header> </header>
</div> </div>
</div> </div>
<?php <?php
$featured_post_count ++; ++$featured_post_count;
endwhile; endwhile;
echo '</div>'; echo '</div>';
endif; endif;
echo '</div>'; echo '</div>';
} }
?> ?>
</div> </div>
</div> </div>
<?php <?php
} }
endif; endif;
@@ -531,45 +540,47 @@ if ( ! function_exists( 'sophia_after_dark_bottom_footer' ) ) :
* function to display bottom footer section * function to display bottom footer section
*/ */
function sophia_after_dark_bottom_footer() { function sophia_after_dark_bottom_footer() {
?> ?>
<div id="bottom-footer"> <div id="bottom-footer">
<div class="sad-container"> <div class="sad-container">
<?php <?php
$sophia_after_dark_enable_footer_menu = get_theme_mod( 'sophia_after_dark_enable_footer_menu', true ); $sophia_after_dark_enable_footer_menu = get_theme_mod( 'sophia_after_dark_enable_footer_menu', true );
if ( true === $sophia_after_dark_enable_footer_menu ) { if ( true === $sophia_after_dark_enable_footer_menu ) {
?> ?>
<nav id="footer-navigation" class="footer-navigation"> <nav id="footer-navigation" class="footer-navigation">
<?php <?php
wp_nav_menu( array( wp_nav_menu(
'theme_location' => 'footer_menu', array(
'menu_id' => 'footer-menu', 'theme_location' => 'footer_menu',
'fallback_cb' => false, 'menu_id' => 'footer-menu',
'depth' => 1 'fallback_cb' => false,
) ); 'depth' => 1,
?> )
</nav> );
<?php ?>
} </nav>
?> <?php
}
?>
<div class="site-info"> <div class="site-info">
<span class="sad-copyright-text"> <span class="sad-copyright-text">
<?php <?php
$sophia_after_dark_footer_copyright = get_theme_mod( 'sophia_after_dark_footer_copyright', __( 'Sophia After Dark', 'sophia-after-dark' ) ); $sophia_after_dark_footer_copyright = get_theme_mod( 'sophia_after_dark_footer_copyright', __( 'Sophia After Dark', 'sophia-after-dark' ) );
echo esc_html( $sophia_after_dark_footer_copyright ); echo esc_html( $sophia_after_dark_footer_copyright );
?> ?>
</span> </span>
<br> <br>
<span class="sad-disclaimer-text"> <span class="sad-disclaimer-text">
<?php <?php
$sophia_after_dark_footer_disclaimer = get_theme_mod( 'sophia_after_dark_footer_disclaimer', __( 'Sophia After Dark', 'sophia-after-dark' ) ); $sophia_after_dark_footer_disclaimer = get_theme_mod( 'sophia_after_dark_footer_disclaimer', __( 'Sophia After Dark', 'sophia-after-dark' ) );
echo esc_html( $sophia_after_dark_footer_disclaimer ); echo esc_html( $sophia_after_dark_footer_disclaimer );
?> ?>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<?php <?php
} }
endif; endif;

View File

@@ -32,46 +32,47 @@ endif;
if ( ! function_exists( 'sophia_after_dark_trending_section' ) ) : if ( ! function_exists( 'sophia_after_dark_trending_section' ) ) :
/** /**
* function to display the trending tags sections * function to display the trending tags sections
* */
*/ function sophia_after_dark_trending_section() {
function sophia_after_dark_trending_section() {
$sophia_after_dark_enable_trending = get_theme_mod( 'sophia_after_dark_enable_trending', false ); $sophia_after_dark_enable_trending = get_theme_mod( 'sophia_after_dark_enable_trending', false );
if ( false === $sophia_after_dark_enable_trending ){ if ( false === $sophia_after_dark_enable_trending ) {
return; return;
} }
$sophia_after_dark_enable_trending_tag_before_icon = get_theme_mod( 'sophia_after_dark_enable_trending_tag_before_icon', true ); $sophia_after_dark_enable_trending_tag_before_icon = get_theme_mod( 'sophia_after_dark_enable_trending_tag_before_icon', true );
if ( $sophia_after_dark_enable_trending_tag_before_icon === true ){ if ( $sophia_after_dark_enable_trending_tag_before_icon === true ) {
$before_icon = 'tag-before-icon'; $before_icon = 'tag-before-icon';
}else{ } else {
$before_icon = ''; $before_icon = '';
} }
$trending_label = get_theme_mod( 'sophia_after_dark_trending_label', __( 'Trending Now', 'sophia-after-dark' ) ); $trending_label = get_theme_mod( 'sophia_after_dark_trending_label', __( 'Trending Now', 'sophia-after-dark' ) );
?> ?>
<div class="trending-wrapper <?php echo esc_html( $before_icon ); ?>"> <div class="trending-wrapper <?php echo esc_html( $before_icon ); ?>">
<span class="wrap-label"><i class="fa fa-bolt" aria-hidden="true"></i> <?php echo esc_html( $trending_label ); ?></span> <span class="wrap-label"><i class="fa fa-bolt" aria-hidden="true"></i> <?php echo esc_html( $trending_label ); ?></span>
<div class="tags-wrapper"> <div class="tags-wrapper">
<?php <?php
$sophia_after_dark_trending_tags_orderby = get_theme_mod( 'sophia_after_dark_trending_tags_orderby', '' ); $sophia_after_dark_trending_tags_orderby = get_theme_mod( 'sophia_after_dark_trending_tags_orderby', '' );
$sophia_after_dark_trending_tags_count = get_theme_mod( 'sophia_after_dark_trending_tags_count', '5' ); $sophia_after_dark_trending_tags_count = get_theme_mod( 'sophia_after_dark_trending_tags_count', '5' );
$get_tags_lists = get_tags( array( $get_tags_lists = get_tags(
'order' => 'DESC', array(
'orderby'=> esc_attr( $sophia_after_dark_trending_tags_orderby ), 'order' => 'DESC',
'number' => absint( $sophia_after_dark_trending_tags_count ), 'orderby' => esc_attr( $sophia_after_dark_trending_tags_orderby ),
)); 'number' => absint( $sophia_after_dark_trending_tags_count ),
if ( !empty( $get_tags_lists ) ) { )
echo '<span class="head-tags-links">'; );
foreach( $get_tags_lists as $tag ) { if ( ! empty( $get_tags_lists ) ) {
echo '<a href="'.esc_html( get_tag_link( $tag->term_id ) ).'" rel="tag">'. esc_html( $tag->name ) .'</a>'; echo '<span class="head-tags-links">';
} foreach ( $get_tags_lists as $tag ) {
echo '</span>'; echo '<a href="' . esc_html( get_tag_link( $tag->term_id ) ) . '" rel="tag">' . esc_html( $tag->name ) . '</a>';
} }
?> echo '</span>';
</div> }
</div> ?>
<?php </div>
} </div>
<?php
}
endif; endif;
@@ -86,26 +87,28 @@ if ( ! function_exists( 'sophia_after_dark_top_header_nav' ) ) :
if ( true === $sophia_after_dark_enable_live_now ) { if ( true === $sophia_after_dark_enable_live_now ) {
$sophia_after_dark_live_now_label = get_theme_mod( 'sophia_after_dark_live_now_label', __( 'Live Now', 'sophia-after-dark' ) ); $sophia_after_dark_live_now_label = get_theme_mod( 'sophia_after_dark_live_now_label', __( 'Live Now', 'sophia-after-dark' ) );
$sophia_after_dark_live_now_link = get_theme_mod( 'sophia_after_dark_live_now_link' ); $sophia_after_dark_live_now_link = get_theme_mod( 'sophia_after_dark_live_now_link' );
?> ?>
<div class="sad-live-link"> <div class="sad-live-link">
<a href="<?php echo esc_url( $sophia_after_dark_live_now_link ); ?>" target="_blank"> <i class="fa fa-play-circle-o" aria-hidden="true"></i><?php echo esc_html( $sophia_after_dark_live_now_label ); ?></a> <a href="<?php echo esc_url( $sophia_after_dark_live_now_link ); ?>" target="_blank"> <i class="fa fa-play-circle-o" aria-hidden="true"></i><?php echo esc_html( $sophia_after_dark_live_now_label ); ?></a>
</div> </div>
<?php <?php
} }
?> ?>
<div class="top-header-nav"> <div class="top-header-nav">
<nav itemscope id="top-navigation" class="main-navigation"> <nav itemscope id="top-navigation" class="main-navigation">
<?php <?php
wp_nav_menu( array( wp_nav_menu(
'theme_location' => 'top_header_menu', array(
'menu_id' => 'top-header-menu', 'theme_location' => 'top_header_menu',
'fallback_cb' => false, 'menu_id' => 'top-header-menu',
) ); 'fallback_cb' => false,
)
);
?> ?>
</nav> </nav>
</div> </div>
<?php <?php
} }
endif; endif;

View File

@@ -17,31 +17,37 @@
*/ */
function sophia_after_dark_jetpack_setup() { function sophia_after_dark_jetpack_setup() {
// Add theme support for Infinite Scroll. // Add theme support for Infinite Scroll.
add_theme_support( 'infinite-scroll', array( add_theme_support(
'container' => 'main', 'infinite-scroll',
'render' => 'sophia_after_dark_infinite_scroll_render', array(
'footer' => 'page' 'container' => 'main',
) ); 'render' => 'sophia_after_dark_infinite_scroll_render',
'footer' => 'page',
)
);
// Add theme support for Responsive Videos. // Add theme support for Responsive Videos.
add_theme_support( 'jetpack-responsive-videos' ); add_theme_support( 'jetpack-responsive-videos' );
// Add theme support for Content Options // Add theme support for Content Options
add_theme_support( 'jetpack-content-options', array( add_theme_support(
'post-details' => array( 'jetpack-content-options',
'stylesheet' => 'sophia-after-dark-style', array(
'date' => '.posted-on', 'post-details' => array(
'categories' => '.cat-links', 'stylesheet' => 'sophia-after-dark-style',
'tags' => '.tags-links', 'date' => '.posted-on',
'author' => '.byline', 'categories' => '.cat-links',
'comment' => '.comments-link', 'tags' => '.tags-links',
), 'author' => '.byline',
'featured-images' => array( 'comment' => '.comments-link',
'archive' => true, ),
'post' => true, 'featured-images' => array(
'page' => true, 'archive' => true,
), 'post' => true,
) ); 'page' => true,
),
)
);
} }
add_action( 'after_setup_theme', 'sophia_after_dark_jetpack_setup' ); add_action( 'after_setup_theme', 'sophia_after_dark_jetpack_setup' );

View File

@@ -12,105 +12,104 @@ add_action( 'add_meta_boxes', 'sophia_after_dark_sidebar_metaboxes', 10, 2 );
function sophia_after_dark_sidebar_metaboxes() { function sophia_after_dark_sidebar_metaboxes() {
add_meta_box( add_meta_box(
'sophia_after_dark_post_sidebar', 'sophia_after_dark_post_sidebar',
__( 'Sidebar Layout', 'sophia-after-dark' ), __( 'Sidebar Layout', 'sophia-after-dark' ),
'sophia_after_dark_sidebar_callback', 'sophia_after_dark_sidebar_callback',
'post', 'post',
'normal', 'normal',
'default' 'default'
); );
add_meta_box(
'sophia_after_dark_post_sidebar',
__( 'Sidebar Layout', 'sophia-after-dark' ),
'sophia_after_dark_sidebar_callback',
'page',
'normal',
'default'
);
add_meta_box(
'sophia_after_dark_post_sidebar',
__( 'Sidebar Layout', 'sophia-after-dark' ),
'sophia_after_dark_sidebar_callback',
'page',
'normal',
'default'
);
} }
/*----------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------*/
function sophia_after_dark_sidebar_callback( $post ) { function sophia_after_dark_sidebar_callback( $post ) {
// Setup our options. // Setup our options.
$sophia_after_dark_page_sidebar_option = array( $sophia_after_dark_page_sidebar_option = array(
'default-sidebar' => array( 'default-sidebar' => array(
'id' => 'post-default-sidebar', 'id' => 'post-default-sidebar',
'value' => 'layout--default-sidebar', 'value' => 'layout--default-sidebar',
'label' => __( 'Default Sidebar', 'sophia-after-dark' ), 'label' => __( 'Default Sidebar', 'sophia-after-dark' ),
'thumbnail' => get_template_directory_uri() . '/assets/images/default-sidebar.png' 'thumbnail' => get_template_directory_uri() . '/assets/images/default-sidebar.png',
), ),
'left-sidebar' => array( 'left-sidebar' => array(
'id' => 'post-left-sidebar', 'id' => 'post-left-sidebar',
'value' => 'left-sidebar', 'value' => 'left-sidebar',
'label' => __( 'Left sidebar', 'sophia-after-dark' ), 'label' => __( 'Left sidebar', 'sophia-after-dark' ),
'thumbnail' => get_template_directory_uri() . '/assets/images/left-sidebar.png' 'thumbnail' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
), ),
'right-sidebar' => array( 'right-sidebar' => array(
'id' => 'post-right-sidebar', 'id' => 'post-right-sidebar',
'value' => 'right-sidebar', 'value' => 'right-sidebar',
'label' => __( 'Right sidebar', 'sophia-after-dark' ), 'label' => __( 'Right sidebar', 'sophia-after-dark' ),
'thumbnail' => get_template_directory_uri() . '/assets/images/right-sidebar.png' 'thumbnail' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
), ),
'no-sidebar' => array( 'no-sidebar' => array(
'id' => 'post-no-sidebar', 'id' => 'post-no-sidebar',
'value' => 'no-sidebar', 'value' => 'no-sidebar',
'label' => __( 'No sidebar Full width', 'sophia-after-dark' ), 'label' => __( 'No sidebar Full width', 'sophia-after-dark' ),
'thumbnail' => get_template_directory_uri() . '/assets/images/no-sidebar.png' 'thumbnail' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
), ),
'no-sidebar-center' => array( 'no-sidebar-center' => array(
'id' => 'post-no-sidebar-center', 'id' => 'post-no-sidebar-center',
'value' => 'no-sidebar-center', 'value' => 'no-sidebar-center',
'label' => __( 'No sidebar Content Centered', 'sophia-after-dark' ), 'label' => __( 'No sidebar Content Centered', 'sophia-after-dark' ),
'thumbnail' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png' 'thumbnail' => get_template_directory_uri() . '/assets/images/no-sidebar-center.png',
) ),
); );
// Check for previously set. // Check for previously set.
$post_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true ); $post_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true );
// If it is then we use it otherwise set to default. // If it is then we use it otherwise set to default.
$post_sidebar_layout = ( $post_sidebar_layout ) ? $post_sidebar_layout : 'layout--default-sidebar'; $post_sidebar_layout = ( $post_sidebar_layout ) ? $post_sidebar_layout : 'layout--default-sidebar';
// Create our nonce field. // Create our nonce field.
wp_nonce_field( 'sophia_after_dark_nonce_' . basename( __FILE__ ) , 'sophia_after_dark_sidebar_layout_nonce' ); wp_nonce_field( 'sophia_after_dark_nonce_' . basename( __FILE__ ), 'sophia_after_dark_sidebar_layout_nonce' );
?> ?>
<div class="sad-meta-options-wrap"> <div class="sad-meta-options-wrap">
<div class="buttonset"> <div class="buttonset">
<?php foreach ( $sophia_after_dark_page_sidebar_option as $field ) { ?> <?php foreach ( $sophia_after_dark_page_sidebar_option as $field ) { ?>
<input type="radio" id="<?php echo esc_attr( $field['id'] ); ?>" value="<?php echo esc_attr( $field['value'] ); ?>" name="sophia_after_dark_post_sidebar_layout" <?php checked( $field['value'], $post_sidebar_layout ); ?> /> <input type="radio" id="<?php echo esc_attr( $field['id'] ); ?>" value="<?php echo esc_attr( $field['value'] ); ?>" name="sophia_after_dark_post_sidebar_layout" <?php checked( $field['value'], $post_sidebar_layout ); ?> />
<label for="<?php echo esc_attr( $field['id'] ); ?>"> <label for="<?php echo esc_attr( $field['id'] ); ?>">
<span class="screen-reader-text"><?php echo esc_html( $field['label'] ); ?></span> <span class="screen-reader-text"><?php echo esc_html( $field['label'] ); ?></span>
<img src="<?php echo esc_url( $field['thumbnail'] ); ?>" title="<?php echo esc_attr( $field['label'] ); ?>" alt="<?php echo esc_attr( $field['label'] ); ?>" /> <img src="<?php echo esc_url( $field['thumbnail'] ); ?>" title="<?php echo esc_attr( $field['label'] ); ?>" alt="<?php echo esc_attr( $field['label'] ); ?>" />
</label> </label>
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
<?php <?php
} }
/*----------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------*/
add_action( 'save_post', 'sophia_after_dark_save_post_meta' ); add_action( 'save_post', 'sophia_after_dark_save_post_meta' );
function sophia_after_dark_save_post_meta( $post_id ) { function sophia_after_dark_save_post_meta( $post_id ) {
// Checks save status // Checks save status
$is_autosave = wp_is_post_autosave( $post_id ); $is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id ); $is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST['sophia_after_dark_sidebar_layout_nonce'] ) && wp_verify_nonce( $_POST['sophia_after_dark_sidebar_layout_nonce'], 'sophia_after_dark_nonce_' . basename( __FILE__ ) ) ) ? 'true' : 'false'; $is_valid_nonce = ( isset( $_POST['sophia_after_dark_sidebar_layout_nonce'] ) && wp_verify_nonce( $_POST['sophia_after_dark_sidebar_layout_nonce'], 'sophia_after_dark_nonce_' . basename( __FILE__ ) ) ) ? 'true' : 'false';
// Exits script depending on save status // Exits script depending on save status
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
return; return;
} }
// Check for out input value. // Check for out input value.
if ( isset( $_POST['sophia_after_dark_post_sidebar_layout'] ) ) { if ( isset( $_POST['sophia_after_dark_post_sidebar_layout'] ) ) {
// We validate making sure that the option is something we can expect. // We validate making sure that the option is something we can expect.
$value = in_array( $_POST['sophia_after_dark_post_sidebar_layout'], array( 'no-sidebar', 'left-sidebar', 'right-sidebar', 'no-sidebar-center', 'layout--default-sidebar' ) ) ? $_POST['sophia_after_dark_post_sidebar_layout'] : 'layout--default-sidebar'; $value = in_array( $_POST['sophia_after_dark_post_sidebar_layout'], array( 'no-sidebar', 'left-sidebar', 'right-sidebar', 'no-sidebar-center', 'layout--default-sidebar' ) ) ? $_POST['sophia_after_dark_post_sidebar_layout'] : 'layout--default-sidebar';
// We update our post meta. // We update our post meta.
update_post_meta( $post_id, 'sophia_after_dark_post_sidebar_layout', $value ); update_post_meta( $post_id, 'sophia_after_dark_post_sidebar_layout', $value );
} }
} }

View File

@@ -35,8 +35,9 @@ function breadcrumb_trail( $args = array() ) {
$breadcrumb = apply_filters( 'breadcrumb_trail_object', null, $args ); $breadcrumb = apply_filters( 'breadcrumb_trail_object', null, $args );
if ( ! is_object( $breadcrumb ) ) if ( ! is_object( $breadcrumb ) ) {
$breadcrumb = new Breadcrumb_Trail( $args ); $breadcrumb = new Breadcrumb_Trail( $args );
}
return $breadcrumb->trail(); return $breadcrumb->trail();
} }
@@ -105,7 +106,7 @@ class Breadcrumb_Trail {
* *
* @since 0.6.0 * @since 0.6.0
* @access public * @access public
* @param array $args { * @param array $args {
* @type string $container Container HTML element. nav|div * @type string $container Container HTML element. nav|div
* @type string $before String to output before breadcrumb menu. * @type string $before String to output before breadcrumb menu.
* @type string $after String to output after breadcrumb menu. * @type string $after String to output after breadcrumb menu.
@@ -125,19 +126,19 @@ class Breadcrumb_Trail {
public function __construct( $args = array() ) { public function __construct( $args = array() ) {
$defaults = array( $defaults = array(
'container' => 'nav', 'container' => 'nav',
'before' => '', 'before' => '',
'after' => '', 'after' => '',
'browse_tag' => 'h2', 'browse_tag' => 'h2',
'list_tag' => 'ul', 'list_tag' => 'ul',
'item_tag' => 'li', 'item_tag' => 'li',
'show_on_front' => true, 'show_on_front' => true,
'network' => false, 'network' => false,
'show_title' => true, 'show_title' => true,
'show_browse' => true, 'show_browse' => true,
'labels' => array(), 'labels' => array(),
'post_taxonomy' => array(), 'post_taxonomy' => array(),
'echo' => true 'echo' => true,
); );
// Parse the arguments with the deaults. // Parse the arguments with the deaults.
@@ -210,11 +211,12 @@ class Breadcrumb_Trail {
// Add list item classes. // Add list item classes.
$item_class = 'trail-item'; $item_class = 'trail-item';
if ( 1 === $item_position && 1 < $item_count ) if ( 1 === $item_position && 1 < $item_count ) {
$item_class .= ' trail-begin'; $item_class .= ' trail-begin';
elseif ( $item_count === $item_position ) } elseif ( $item_count === $item_position ) {
$item_class .= ' trail-end'; $item_class .= ' trail-end';
}
// Create list item attributes. // Create list item attributes.
$attributes = 'itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="' . $item_class . '"'; $attributes = 'itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="' . $item_class . '"';
@@ -223,7 +225,7 @@ class Breadcrumb_Trail {
$meta = sprintf( '<meta itemprop="position" content="%s" />', absint( $item_position ) ); $meta = sprintf( '<meta itemprop="position" content="%s" />', absint( $item_position ) );
// Build the list item. // Build the list item.
$breadcrumb .= sprintf( '<%1$s %2$s>%3$s%4$s</%1$s>', tag_escape( $this->args['item_tag'] ),$attributes, $item, $meta ); $breadcrumb .= sprintf( '<%1$s %2$s>%3$s%4$s</%1$s>', tag_escape( $this->args['item_tag'] ), $attributes, $item, $meta );
} }
// Close the unordered list. // Close the unordered list.
@@ -243,8 +245,9 @@ class Breadcrumb_Trail {
// Allow developers to filter the breadcrumb trail HTML. // Allow developers to filter the breadcrumb trail HTML.
$breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb, $this->args ); $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb, $this->args );
if ( false === $this->args['echo'] ) if ( false === $this->args['echo'] ) {
return $breadcrumb; return $breadcrumb;
}
echo $breadcrumb; echo $breadcrumb;
} }
@@ -261,21 +264,21 @@ class Breadcrumb_Trail {
protected function set_labels() { protected function set_labels() {
$defaults = array( $defaults = array(
'browse' => esc_html__( 'Browse:', 'sophia-after-dark' ), 'browse' => esc_html__( 'Browse:', 'sophia-after-dark' ),
'aria_label' => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'sophia-after-dark' ), 'aria_label' => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'sophia-after-dark' ),
'home' => esc_html__( 'Home', 'sophia-after-dark' ), 'home' => esc_html__( 'Home', 'sophia-after-dark' ),
'error_404' => esc_html__( '404 Not Found', 'sophia-after-dark' ), 'error_404' => esc_html__( '404 Not Found', 'sophia-after-dark' ),
'archives' => esc_html__( 'Archives', 'sophia-after-dark' ), 'archives' => esc_html__( 'Archives', 'sophia-after-dark' ),
// Translators: %s is the search query. // Translators: %s is the search query.
'search' => esc_html__( 'Search results for: %s', 'sophia-after-dark' ), 'search' => esc_html__( 'Search results for: %s', 'sophia-after-dark' ),
// Translators: %s is the page number. // Translators: %s is the page number.
'paged' => esc_html__( 'Page %s', 'sophia-after-dark' ), 'paged' => esc_html__( 'Page %s', 'sophia-after-dark' ),
// Translators: %s is the page number. // Translators: %s is the page number.
'paged_comments' => esc_html__( 'Comment Page %s', 'sophia-after-dark' ), 'paged_comments' => esc_html__( 'Comment Page %s', 'sophia-after-dark' ),
// Translators: Minute archive title. %s is the minute time format. // Translators: Minute archive title. %s is the minute time format.
'archive_minute' => esc_html__( 'Minute %s', 'sophia-after-dark' ), 'archive_minute' => esc_html__( 'Minute %s', 'sophia-after-dark' ),
// Translators: Weekly archive title. %s is the week date format. // Translators: Weekly archive title. %s is the week date format.
'archive_week' => esc_html__( 'Week %s', 'sophia-after-dark' ), 'archive_week' => esc_html__( 'Week %s', 'sophia-after-dark' ),
// "%s" is replaced with the translated date/time format. // "%s" is replaced with the translated date/time format.
'archive_minute_hour' => '%s', 'archive_minute_hour' => '%s',
@@ -301,8 +304,9 @@ class Breadcrumb_Trail {
$defaults = array(); $defaults = array();
// If post permalink is set to `%postname%`, use the `category` taxonomy. // If post permalink is set to `%postname%`, use the `category` taxonomy.
if ( '%postname%' === trim( get_option( 'permalink_structure' ), '/' ) ) if ( '%postname%' === trim( get_option( 'permalink_structure' ), '/' ) ) {
$defaults['post'] = 'category'; $defaults['post'] = 'category';
}
$this->post_taxonomy = apply_filters( 'breadcrumb_trail_post_taxonomy', wp_parse_args( $this->args['post_taxonomy'], $defaults ) ); $this->post_taxonomy = apply_filters( 'breadcrumb_trail_post_taxonomy', wp_parse_args( $this->args['post_taxonomy'], $defaults ) );
} }
@@ -342,38 +346,39 @@ class Breadcrumb_Trail {
// If viewing an archive page. // If viewing an archive page.
elseif ( is_archive() ) { elseif ( is_archive() ) {
if ( is_post_type_archive() ) if ( is_post_type_archive() ) {
$this->add_post_type_archive_items(); $this->add_post_type_archive_items();
elseif ( is_category() || is_tag() || is_tax() ) } elseif ( is_category() || is_tag() || is_tax() ) {
$this->add_term_archive_items(); $this->add_term_archive_items();
elseif ( is_author() ) } elseif ( is_author() ) {
$this->add_user_archive_items(); $this->add_user_archive_items();
elseif ( get_query_var( 'minute' ) && get_query_var( 'hour' ) ) } elseif ( get_query_var( 'minute' ) && get_query_var( 'hour' ) ) {
$this->add_minute_hour_archive_items(); $this->add_minute_hour_archive_items();
elseif ( get_query_var( 'minute' ) ) } elseif ( get_query_var( 'minute' ) ) {
$this->add_minute_archive_items(); $this->add_minute_archive_items();
elseif ( get_query_var( 'hour' ) ) } elseif ( get_query_var( 'hour' ) ) {
$this->add_hour_archive_items(); $this->add_hour_archive_items();
elseif ( is_day() ) } elseif ( is_day() ) {
$this->add_day_archive_items(); $this->add_day_archive_items();
elseif ( get_query_var( 'w' ) ) } elseif ( get_query_var( 'w' ) ) {
$this->add_week_archive_items(); $this->add_week_archive_items();
elseif ( is_month() ) } elseif ( is_month() ) {
$this->add_month_archive_items(); $this->add_month_archive_items();
elseif ( is_year() ) } elseif ( is_year() ) {
$this->add_year_archive_items(); $this->add_year_archive_items();
else } else {
$this->add_default_archive_items(); $this->add_default_archive_items();
}
} }
// If viewing a search results page. // If viewing a search results page.
@@ -404,8 +409,9 @@ class Breadcrumb_Trail {
protected function add_rewrite_front_items() { protected function add_rewrite_front_items() {
global $wp_rewrite; global $wp_rewrite;
if ( $wp_rewrite->front ) if ( $wp_rewrite->front ) {
$this->add_path_parents( $wp_rewrite->front ); $this->add_path_parents( $wp_rewrite->front );
}
} }
/** /**
@@ -418,16 +424,19 @@ class Breadcrumb_Trail {
protected function add_paged_items() { protected function add_paged_items() {
// If viewing a paged singular post. // If viewing a paged singular post.
if ( is_singular() && 1 < get_query_var( 'page' ) && true === $this->args['show_title'] ) if ( is_singular() && 1 < get_query_var( 'page' ) && true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'page' ) ) ) ); $this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'page' ) ) ) );
}
// If viewing a singular post with paged comments. // If viewing a singular post with paged comments.
elseif ( is_singular() && get_option( 'page_comments' ) && 1 < get_query_var( 'cpage' ) ) elseif ( is_singular() && get_option( 'page_comments' ) && 1 < get_query_var( 'cpage' ) ) {
$this->items[] = sprintf( $this->labels['paged_comments'], number_format_i18n( absint( get_query_var( 'cpage' ) ) ) ); $this->items[] = sprintf( $this->labels['paged_comments'], number_format_i18n( absint( get_query_var( 'cpage' ) ) ) );
}
// If viewing a paged archive-type page. // If viewing a paged archive-type page.
elseif ( is_paged() && true === $this->args['show_title'] ) elseif ( is_paged() && true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'paged' ) ) ) ); $this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'paged' ) ) ) );
}
} }
/** /**
@@ -439,8 +448,9 @@ class Breadcrumb_Trail {
*/ */
protected function add_network_home_link() { protected function add_network_home_link() {
if ( is_multisite() && ! is_main_site() && true === $this->args['network'] ) if ( is_multisite() && ! is_main_site() && true === $this->args['network'] ) {
$this->items[] = sprintf( '<a href="%s" rel="home">%s</a>', esc_url( network_home_url() ), $this->labels['home'] ); $this->items[] = sprintf( '<a href="%s" rel="home">%s</a>', esc_url( network_home_url() ), $this->labels['home'] );
}
} }
/** /**
@@ -475,12 +485,14 @@ class Breadcrumb_Trail {
$this->add_network_home_link(); $this->add_network_home_link();
// If on a paged view, add the site home link. // If on a paged view, add the site home link.
if ( is_paged() ) if ( is_paged() ) {
$this->add_site_home_link(); $this->add_site_home_link();
}
// If on the main front page, add the network home title. // If on the main front page, add the network home title.
elseif ( true === $this->args['show_title'] ) elseif ( true === $this->args['show_title'] ) {
$this->items[] = is_multisite() && true === $this->args['network'] ? get_bloginfo( 'name' ) : $this->labels['home']; $this->items[] = is_multisite() && true === $this->args['network'] ? get_bloginfo( 'name' ) : $this->labels['home'];
}
} }
} }
@@ -498,18 +510,20 @@ class Breadcrumb_Trail {
$post = get_post( $post_id ); $post = get_post( $post_id );
// If the post has parents, add them to the trail. // If the post has parents, add them to the trail.
if ( 0 < $post->post_parent ) if ( 0 < $post->post_parent ) {
$this->add_post_parents( $post->post_parent ); $this->add_post_parents( $post->post_parent );
}
// Get the page title. // Get the page title.
$title = get_the_title( $post_id ); $title = get_the_title( $post_id );
// Add the posts page item. // Add the posts page item.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), $title ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), $title );
elseif ( $title && true === $this->args['show_title'] ) } elseif ( $title && true === $this->args['show_title'] ) {
$this->items[] = $title; $this->items[] = $title;
}
} }
/** /**
@@ -526,25 +540,29 @@ class Breadcrumb_Trail {
$post_id = get_queried_object_id(); $post_id = get_queried_object_id();
// If the post has a parent, follow the parent trail. // If the post has a parent, follow the parent trail.
if ( 0 < $post->post_parent ) if ( 0 < $post->post_parent ) {
$this->add_post_parents( $post->post_parent ); $this->add_post_parents( $post->post_parent );
}
// If the post doesn't have a parent, get its hierarchy based off the post type. // If the post doesn't have a parent, get its hierarchy based off the post type.
else else {
$this->add_post_hierarchy( $post_id ); $this->add_post_hierarchy( $post_id );
}
// Display terms for specific post type taxonomy if requested. // Display terms for specific post type taxonomy if requested.
if ( ! empty( $this->post_taxonomy[ $post->post_type ] ) ) if ( ! empty( $this->post_taxonomy[ $post->post_type ] ) ) {
$this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] ); $this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] );
}
// End with the post title. // End with the post title.
if ( $post_title = single_post_title( '', false ) ) { if ( $post_title = single_post_title( '', false ) ) {
if ( ( 1 < get_query_var( 'page' ) || is_paged() ) || ( get_option( 'page_comments' ) && 1 < absint( get_query_var( 'cpage' ) ) ) ) if ( ( 1 < get_query_var( 'page' ) || is_paged() ) || ( get_option( 'page_comments' ) && 1 < absint( get_query_var( 'cpage' ) ) ) ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), $post_title ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), $post_title );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = $post_title; $this->items[] = $post_title;
}
} }
} }
@@ -568,8 +586,9 @@ class Breadcrumb_Trail {
if ( false !== $taxonomy->rewrite ) { if ( false !== $taxonomy->rewrite ) {
// If 'with_front' is true, dd $wp_rewrite->front to the trail. // If 'with_front' is true, dd $wp_rewrite->front to the trail.
if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
}
// Get parent pages by path if they exist. // Get parent pages by path if they exist.
$this->add_path_parents( $taxonomy->rewrite['slug'] ); $this->add_path_parents( $taxonomy->rewrite['slug'] );
@@ -629,10 +648,11 @@ class Breadcrumb_Trail {
if ( 'post' === $taxonomy->object_type[0] ) { if ( 'post' === $taxonomy->object_type[0] ) {
$post_id = get_option( 'page_for_posts' ); $post_id = get_option( 'page_for_posts' );
if ( 'posts' !== get_option( 'show_on_front' ) && 0 < $post_id ) if ( 'posts' !== get_option( 'show_on_front' ) && 0 < $post_id ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) );
}
// If the post type is not 'post'. // If the post type is not 'post'.
} else { } else {
$post_type_object = get_post_type_object( $taxonomy->object_type[0] ); $post_type_object = get_post_type_object( $taxonomy->object_type[0] );
@@ -646,15 +666,17 @@ class Breadcrumb_Trail {
} }
// If the taxonomy is hierarchical, list its parent terms. // If the taxonomy is hierarchical, list its parent terms.
if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent ) if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent ) {
$this->add_term_parents( $term->parent, $term->taxonomy ); $this->add_term_parents( $term->parent, $term->taxonomy );
}
// Add the term name to the trail end. // Add the term name to the trail end.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $term->taxonomy ) ), single_term_title( '', false ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $term->taxonomy ) ), single_term_title( '', false ) );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = single_term_title( '', false ); $this->items[] = single_term_title( '', false );
}
} }
/** /**
@@ -672,24 +694,28 @@ class Breadcrumb_Trail {
if ( false !== $post_type_object->rewrite ) { if ( false !== $post_type_object->rewrite ) {
// If 'with_front' is true, add $wp_rewrite->front to the trail. // If 'with_front' is true, add $wp_rewrite->front to the trail.
if ( $post_type_object->rewrite['with_front'] ) if ( $post_type_object->rewrite['with_front'] ) {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
}
// If there's a rewrite slug, check for parents. // If there's a rewrite slug, check for parents.
if ( ! empty( $post_type_object->rewrite['slug'] ) ) if ( ! empty( $post_type_object->rewrite['slug'] ) ) {
$this->add_path_parents( $post_type_object->rewrite['slug'] ); $this->add_path_parents( $post_type_object->rewrite['slug'] );
}
} }
// Add the post type [plural] name to the trail end. // Add the post type [plural] name to the trail end.
if ( is_paged() || is_author() ) if ( is_paged() || is_author() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_post_type_archive_link( $post_type_object->name ) ), post_type_archive_title( '', false ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_post_type_archive_link( $post_type_object->name ) ), post_type_archive_title( '', false ) );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = post_type_archive_title( '', false ); $this->items[] = post_type_archive_title( '', false );
}
// If viewing a post type archive by author. // If viewing a post type archive by author.
if ( is_author() ) if ( is_author() ) {
$this->add_user_archive_items(); $this->add_user_archive_items();
}
} }
/** /**
@@ -710,15 +736,17 @@ class Breadcrumb_Trail {
$user_id = get_query_var( 'author' ); $user_id = get_query_var( 'author' );
// If $author_base exists, check for parent pages. // If $author_base exists, check for parent pages.
if ( ! empty( $wp_rewrite->author_base ) && ! is_post_type_archive() ) if ( ! empty( $wp_rewrite->author_base ) && ! is_post_type_archive() ) {
$this->add_path_parents( $wp_rewrite->author_base ); $this->add_path_parents( $wp_rewrite->author_base );
}
// Add the author's display name to the trail end. // Add the author's display name to the trail end.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_author_posts_url( $user_id ) ), get_the_author_meta( 'display_name', $user_id ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_author_posts_url( $user_id ) ), get_the_author_meta( 'display_name', $user_id ) );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = get_the_author_meta( 'display_name', $user_id ); $this->items[] = get_the_author_meta( 'display_name', $user_id );
}
} }
/** /**
@@ -734,8 +762,9 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Add the minute + hour item. // Add the minute + hour item.
if ( true === $this->args['show_title'] ) if ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['archive_minute_hour'], get_the_time( esc_html_x( 'g:i a', 'minute and hour archives time format', 'sophia-after-dark' ) ) ); $this->items[] = sprintf( $this->labels['archive_minute_hour'], get_the_time( esc_html_x( 'g:i a', 'minute and hour archives time format', 'sophia-after-dark' ) ) );
}
} }
/** /**
@@ -751,8 +780,9 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Add the minute item. // Add the minute item.
if ( true === $this->args['show_title'] ) if ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['archive_minute'], get_the_time( esc_html_x( 'i', 'minute archives time format', 'sophia-after-dark' ) ) ); $this->items[] = sprintf( $this->labels['archive_minute'], get_the_time( esc_html_x( 'i', 'minute archives time format', 'sophia-after-dark' ) ) );
}
} }
/** /**
@@ -768,8 +798,9 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Add the hour item. // Add the hour item.
if ( true === $this->args['show_title'] ) if ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['archive_hour'], get_the_time( esc_html_x( 'g a', 'hour archives time format', 'sophia-after-dark' ) ) ); $this->items[] = sprintf( $this->labels['archive_hour'], get_the_time( esc_html_x( 'g a', 'hour archives time format', 'sophia-after-dark' ) ) );
}
} }
/** /**
@@ -785,20 +816,21 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Get year, month, and day. // Get year, month, and day.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) ); $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) );
$month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sophia-after-dark' ) ) ); $month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sophia-after-dark' ) ) );
$day = sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'sophia-after-dark' ) ) ); $day = sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'sophia-after-dark' ) ) );
// Add the year and month items. // Add the year and month items.
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month );
// Add the day item. // Add the day item.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_day_link( get_the_time( 'Y' ) ), get_the_time( 'm' ), get_the_time( 'd' ) ), $day ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_day_link( get_the_time( 'Y' ) ), get_the_time( 'm' ), get_the_time( 'd' ) ), $day );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = $day; $this->items[] = $day;
}
} }
/** /**
@@ -814,18 +846,31 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Get the year and week. // Get the year and week.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) ); $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) );
$week = sprintf( $this->labels['archive_week'], get_the_time( esc_html_x( 'W', 'weekly archives date format', 'sophia-after-dark' ) ) ); $week = sprintf( $this->labels['archive_week'], get_the_time( esc_html_x( 'W', 'weekly archives date format', 'sophia-after-dark' ) ) );
// Add the year item. // Add the year item.
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
// Add the week item. // Add the week item.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = esc_url( get_archives_link( add_query_arg( array( 'm' => get_the_time( 'Y' ), 'w' => get_the_time( 'W' ) ), home_url() ), $week, false ) ); $this->items[] = esc_url(
get_archives_link(
add_query_arg(
array(
'm' => get_the_time( 'Y' ),
'w' => get_the_time( 'W' ),
),
home_url()
),
$week,
false
)
);
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = $week; $this->items[] = $week;
}
} }
/** /**
@@ -841,18 +886,19 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Get the year and month. // Get the year and month.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) ); $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) );
$month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sophia-after-dark' ) ) ); $month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sophia-after-dark' ) ) );
// Add the year item. // Add the year item.
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
// Add the month item. // Add the month item.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = $month; $this->items[] = $month;
}
} }
/** /**
@@ -868,14 +914,15 @@ class Breadcrumb_Trail {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
// Get the year. // Get the year.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) ); $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) );
// Add the year item. // Add the year item.
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = $year; $this->items[] = $year;
}
} }
/** /**
@@ -889,11 +936,13 @@ class Breadcrumb_Trail {
protected function add_default_archive_items() { protected function add_default_archive_items() {
// If this is a date-/time-based archive, add $wp_rewrite->front to the trail. // If this is a date-/time-based archive, add $wp_rewrite->front to the trail.
if ( is_date() || is_time() ) if ( is_date() || is_time() ) {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
}
if ( true === $this->args['show_title'] ) if ( true === $this->args['show_title'] ) {
$this->items[] = $this->labels['archives']; $this->items[] = $this->labels['archives'];
}
} }
/** /**
@@ -905,11 +954,12 @@ class Breadcrumb_Trail {
*/ */
protected function add_search_items() { protected function add_search_items() {
if ( is_paged() ) if ( is_paged() ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_search_link() ), sprintf( $this->labels['search'], get_search_query() ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_search_link() ), sprintf( $this->labels['search'], get_search_query() ) );
elseif ( true === $this->args['show_title'] ) } elseif ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['search'], get_search_query() ); $this->items[] = sprintf( $this->labels['search'], get_search_query() );
}
} }
/** /**
@@ -921,8 +971,9 @@ class Breadcrumb_Trail {
*/ */
protected function add_404_items() { protected function add_404_items() {
if ( true === $this->args['show_title'] ) if ( true === $this->args['show_title'] ) {
$this->items[] = $this->labels['error_404']; $this->items[] = $this->labels['error_404'];
}
} }
/** /**
@@ -930,7 +981,7 @@ class Breadcrumb_Trail {
* *
* @since 1.0.0 * @since 1.0.0
* @access protected * @access protected
* @param int $post_id * @param int $post_id
* @return void * @return void
*/ */
protected function add_post_parents( $post_id ) { protected function add_post_parents( $post_id ) {
@@ -942,15 +993,17 @@ class Breadcrumb_Trail {
$post = get_post( $post_id ); $post = get_post( $post_id );
// If we hit a page that's set as the front page, bail. // If we hit a page that's set as the front page, bail.
if ( 'page' == $post->post_type && 'page' == get_option( 'show_on_front' ) && $post_id == get_option( 'page_on_front' ) ) if ( 'page' == $post->post_type && 'page' == get_option( 'show_on_front' ) && $post_id == get_option( 'page_on_front' ) ) {
break; break;
}
// Add the formatted post link to the array of parents. // Add the formatted post link to the array of parents.
$parents[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) ); $parents[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) );
// If there's no longer a post parent, break out of the loop. // If there's no longer a post parent, break out of the loop.
if ( 0 >= $post->post_parent ) if ( 0 >= $post->post_parent ) {
break; break;
}
// Change the post ID to the parent post to continue looping. // Change the post ID to the parent post to continue looping.
$post_id = $post->post_parent; $post_id = $post->post_parent;
@@ -960,8 +1013,9 @@ class Breadcrumb_Trail {
$this->add_post_hierarchy( $post_id ); $this->add_post_hierarchy( $post_id );
// Display terms for specific post type taxonomy if requested. // Display terms for specific post type taxonomy if requested.
if ( ! empty( $this->post_taxonomy[ $post->post_type ] ) ) if ( ! empty( $this->post_taxonomy[ $post->post_type ] ) ) {
$this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] ); $this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] );
}
// Merge the parent items into the items array. // Merge the parent items into the items array.
$this->items = array_merge( $this->items, array_reverse( $parents ) ); $this->items = array_merge( $this->items, array_reverse( $parents ) );
@@ -973,7 +1027,7 @@ class Breadcrumb_Trail {
* *
* @since 1.0.0 * @since 1.0.0
* @access protected * @access protected
* @param int $post_id * @param int $post_id
* @return void * @return void
*/ */
protected function add_post_hierarchy( $post_id ) { protected function add_post_hierarchy( $post_id ) {
@@ -996,12 +1050,14 @@ class Breadcrumb_Trail {
elseif ( false !== $post_type_object->rewrite ) { elseif ( false !== $post_type_object->rewrite ) {
// If 'with_front' is true, add $wp_rewrite->front to the trail. // If 'with_front' is true, add $wp_rewrite->front to the trail.
if ( $post_type_object->rewrite['with_front'] ) if ( $post_type_object->rewrite['with_front'] ) {
$this->add_rewrite_front_items(); $this->add_rewrite_front_items();
}
// If there's a path, check for parents. // If there's a path, check for parents.
if ( ! empty( $post_type_object->rewrite['slug'] ) ) if ( ! empty( $post_type_object->rewrite['slug'] ) ) {
$this->add_path_parents( $post_type_object->rewrite['slug'] ); $this->add_path_parents( $post_type_object->rewrite['slug'] );
}
} }
// If there's an archive page, add it to the trail. // If there's an archive page, add it to the trail.
@@ -1017,8 +1073,9 @@ class Breadcrumb_Trail {
} }
// Map the rewrite tags if there's a `%` in the slug. // Map the rewrite tags if there's a `%` in the slug.
if ( 'post' !== $post_type && ! empty( $post_type_object->rewrite['slug'] ) && false !== strpos( $post_type_object->rewrite['slug'], '%' ) ) if ( 'post' !== $post_type && ! empty( $post_type_object->rewrite['slug'] ) && false !== strpos( $post_type_object->rewrite['slug'], '%' ) ) {
$this->map_rewrite_tags( $post_id, $post_type_object->rewrite['slug'] ); $this->map_rewrite_tags( $post_id, $post_type_object->rewrite['slug'] );
}
} }
/** /**
@@ -1027,7 +1084,7 @@ class Breadcrumb_Trail {
* *
* @since 0.6.0 * @since 0.6.0
* @access protected * @access protected
* @param int $slug The post type archive slug to search for. * @param int $slug The post type archive slug to search for.
* @return void * @return void
*/ */
protected function get_post_types_by_slug( $slug ) { protected function get_post_types_by_slug( $slug ) {
@@ -1038,8 +1095,9 @@ class Breadcrumb_Trail {
foreach ( $post_types as $type ) { foreach ( $post_types as $type ) {
if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) ) if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) ) {
$return[] = $type; $return[] = $type;
}
} }
return $return; return $return;
@@ -1050,8 +1108,8 @@ class Breadcrumb_Trail {
* *
* @since 1.0.0 * @since 1.0.0
* @access protected * @access protected
* @param int $post_id The ID of the post to get the terms for. * @param int $post_id The ID of the post to get the terms for.
* @param string $taxonomy The taxonomy to get the terms from. * @param string $taxonomy The taxonomy to get the terms from.
* @return void * @return void
*/ */
protected function add_post_terms( $post_id, $taxonomy ) { protected function add_post_terms( $post_id, $taxonomy ) {
@@ -1066,17 +1124,19 @@ class Breadcrumb_Trail {
if ( $terms && ! is_wp_error( $terms ) ) { if ( $terms && ! is_wp_error( $terms ) ) {
// Sort the terms by ID and get the first category. // Sort the terms by ID and get the first category.
if ( function_exists( 'wp_list_sort' ) ) if ( function_exists( 'wp_list_sort' ) ) {
$terms = wp_list_sort( $terms, 'term_id' ); $terms = wp_list_sort( $terms, 'term_id' );
else } else {
usort( $terms, '_usort_terms_by_ID' ); usort( $terms, '_usort_terms_by_ID' );
}
$term = get_term( $terms[0], $taxonomy ); $term = get_term( $terms[0], $taxonomy );
// If the category has a parent, add the hierarchy to the trail. // If the category has a parent, add the hierarchy to the trail.
if ( 0 < $term->parent ) if ( 0 < $term->parent ) {
$this->add_term_parents( $term->parent, $taxonomy ); $this->add_term_parents( $term->parent, $taxonomy );
}
// Add the category archive link to the trail. // Add the category archive link to the trail.
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $taxonomy ) ), $term->name ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $taxonomy ) ), $term->name );
@@ -1099,21 +1159,20 @@ class Breadcrumb_Trail {
$path = trim( $path, '/' ); $path = trim( $path, '/' );
// If there's no path, return. // If there's no path, return.
if ( empty( $path ) ) if ( empty( $path ) ) {
return; return;
}
// Get parent post by the path. // Get parent post by the path.
$post = get_page_by_path( $path ); $post = get_page_by_path( $path );
if ( ! empty( $post ) ) { if ( ! empty( $post ) ) {
$this->add_post_parents( $post->ID ); $this->add_post_parents( $post->ID );
} } elseif ( is_null( $post ) ) {
elseif ( is_null( $post ) ) {
// Separate post names into separate paths by '/'. // Separate post names into separate paths by '/'.
$path = trim( $path, '/' ); $path = trim( $path, '/' );
preg_match_all( "/\/.*?\z/", $path, $matches ); preg_match_all( '/\/.*?\z/', $path, $matches );
// If matches are found for the path. // If matches are found for the path.
if ( isset( $matches ) ) { if ( isset( $matches ) ) {
@@ -1170,8 +1229,9 @@ class Breadcrumb_Trail {
} }
// If we have parent terms, reverse the array to put them in the proper order for the trail. // If we have parent terms, reverse the array to put them in the proper order for the trail.
if ( ! empty( $parents ) ) if ( ! empty( $parents ) ) {
$this->items = array_merge( $this->items, array_reverse( $parents ) ); $this->items = array_merge( $this->items, array_reverse( $parents ) );
}
} }
/** /**
@@ -1207,20 +1267,24 @@ class Breadcrumb_Trail {
$tag = trim( $match, '/' ); $tag = trim( $match, '/' );
// If using the %year% tag, add a link to the yearly archive. // If using the %year% tag, add a link to the yearly archive.
if ( '%year%' == $tag ) if ( '%year%' == $tag ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y', $post_id ) ) ), sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y', $post_id ) ) ), sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sophia-after-dark' ) ) ) );
}
// If using the %monthnum% tag, add a link to the monthly archive. // If using the %monthnum% tag, add a link to the monthly archive.
elseif ( '%monthnum%' == $tag ) elseif ( '%monthnum%' == $tag ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ) ) ), sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sophia-after-dark' ) ) ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ) ) ), sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sophia-after-dark' ) ) ) );
}
// If using the %day% tag, add a link to the daily archive. // If using the %day% tag, add a link to the daily archive.
elseif ( '%day%' == $tag ) elseif ( '%day%' == $tag ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_day_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ), get_the_time( 'd', $post_id ) ) ), sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'sophia-after-dark' ) ) ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_day_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ), get_the_time( 'd', $post_id ) ) ), sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'sophia-after-dark' ) ) ) );
}
// If using the %author% tag, add a link to the post author archive. // If using the %author% tag, add a link to the post author archive.
elseif ( '%author%' == $tag ) elseif ( '%author%' == $tag ) {
$this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_author_posts_url( $post->post_author ) ), get_the_author_meta( 'display_name', $post->post_author ) ); $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_author_posts_url( $post->post_author ) ), get_the_author_meta( 'display_name', $post->post_author ) );
}
// If using the %category% tag, add a link to the first category archive to match permalinks. // If using the %category% tag, add a link to the first category archive to match permalinks.
elseif ( taxonomy_exists( trim( $tag, '%' ) ) ) { elseif ( taxonomy_exists( trim( $tag, '%' ) ) ) {

View File

@@ -4,48 +4,47 @@
* *
* @package Sophia After Dark * @package Sophia After Dark
* @since 1.0.0 * @since 1.0.0
*
*/ */
add_action( 'wp_enqueue_scripts', 'sophia_after_dark_dynamic_styles' ); add_action( 'wp_enqueue_scripts', 'sophia_after_dark_dynamic_styles' );
if ( ! function_exists( 'sophia_after_dark_dynamic_styles' ) ) : if ( ! function_exists( 'sophia_after_dark_dynamic_styles' ) ) :
function sophia_after_dark_dynamic_styles() { function sophia_after_dark_dynamic_styles() {
$sophia_after_dark_primary_color = get_theme_mod( 'sophia_after_dark_primary_color', '#dd3333' ); $sophia_after_dark_primary_color = get_theme_mod( 'sophia_after_dark_primary_color', '#dd3333' );
$get_categories = get_categories( array( 'hide_empty' => 1 ) ); $get_categories = get_categories( array( 'hide_empty' => 1 ) );
$output_css = ''; $output_css = '';
foreach ( $get_categories as $category ) { foreach ( $get_categories as $category ) {
$cat_color = get_theme_mod( 'sophia_after_dark_category_color_'.$category->slug, '#3b2d1b' ); $cat_color = get_theme_mod( 'sophia_after_dark_category_color_' . $category->slug, '#3b2d1b' );
$cat_hover_color = sophia_after_dark_hover_color( $cat_color, '-50' ); $cat_hover_color = sophia_after_dark_hover_color( $cat_color, '-50' );
$cat_id = $category->term_id; $cat_id = $category->term_id;
if ( !empty( $cat_color ) ) { if ( ! empty( $cat_color ) ) {
$output_css .= ".category-button.cbd-cat-". esc_attr( $cat_id ) ." a { background: ". esc_attr( $cat_color ) ."}\n"; $output_css .= '.category-button.cbd-cat-' . esc_attr( $cat_id ) . ' a { background: ' . esc_attr( $cat_color ) . "}\n";
$output_css .= ".category-button.cbd-cat-". esc_attr( $cat_id ) ." a:hover { background: ". esc_attr( $cat_hover_color ) ."}\n"; $output_css .= '.category-button.cbd-cat-' . esc_attr( $cat_id ) . ' a:hover { background: ' . esc_attr( $cat_hover_color ) . "}\n";
$output_css .= "#site-navigation ul li.cbd-cat-". esc_attr( $cat_id ) ." .menu-item-description { background: ". esc_attr( $cat_color ) ."}\n"; $output_css .= '#site-navigation ul li.cbd-cat-' . esc_attr( $cat_id ) . ' .menu-item-description { background: ' . esc_attr( $cat_color ) . "}\n";
$output_css .= "#site-navigation ul li.cbd-cat-". esc_attr( $cat_id ) ." .menu-item-description:after { border-top-color: ". esc_attr( $cat_color ) ."}\n"; $output_css .= '#site-navigation ul li.cbd-cat-' . esc_attr( $cat_id ) . ' .menu-item-description:after { border-top-color: ' . esc_attr( $cat_color ) . "}\n";
} }
} }
$output_css .= "a,a:hover,a:focus,a:active,.entry-cat .cat-links a:hover,.entry-cat a:hover,.entry-footer a:hover,.comment-author .fn .url:hover,.commentmetadata .comment-edit-link, #cancel-comment-reply-link, #cancel-comment-reply-link:before, .logged-in-as a,.widget a:hover, .widget a:hover::before, .widget li:hover::before,.sad-social-icon-wrap li a:hover,.sad-social-icon-wrap li a:focus,#site-navigation ul li:hover>a,#site-navigation ul li.current-menu-item>a,#site-navigation ul li.current_page_ancestor>a,#site-navigation ul li.current-menu-ancestor>a,#site-navigation ul li.current_page_item>a,#site-navigation ul li.current-menu-parent>a,#site-navigation ul li.focus>a,.banner-sub-title,.entry-title a:hover,.cat-links a:hover,.btn-wrapper a:hover,.navigation.pagination .nav-links .page-numbers.current, .navigation.pagination .nav-links a.page-numbers:hover,#footer-menu li a:hover,.sophia_after_dark_latest_posts .sad-post-title a:hover,#sad-scrollup:hover,.menu-toggle:hover, #top-navigation ul li a:hover,.sad-search-icon:hover, .entry-meta a:hover, .front-slider-block .banner-title a:hover, .post-info-wrap .entry-meta a:hover, .single .sad-single-related-posts .entry-title a:hover, .breadcrumbs .trail-items li a:hover, .wrap-label i,.has-thumbnail .post-info-wrap .entry-title a:hover,.front-slider-block .post-info-wrap .entry-title a:hover,#top-footer a:hover{ color: ". esc_attr( $sophia_after_dark_primary_color ) ."}\n"; $output_css .= 'a,a:hover,a:focus,a:active,.entry-cat .cat-links a:hover,.entry-cat a:hover,.entry-footer a:hover,.comment-author .fn .url:hover,.commentmetadata .comment-edit-link, #cancel-comment-reply-link, #cancel-comment-reply-link:before, .logged-in-as a,.widget a:hover, .widget a:hover::before, .widget li:hover::before,.sad-social-icon-wrap li a:hover,.sad-social-icon-wrap li a:focus,#site-navigation ul li:hover>a,#site-navigation ul li.current-menu-item>a,#site-navigation ul li.current_page_ancestor>a,#site-navigation ul li.current-menu-ancestor>a,#site-navigation ul li.current_page_item>a,#site-navigation ul li.current-menu-parent>a,#site-navigation ul li.focus>a,.banner-sub-title,.entry-title a:hover,.cat-links a:hover,.btn-wrapper a:hover,.navigation.pagination .nav-links .page-numbers.current, .navigation.pagination .nav-links a.page-numbers:hover,#footer-menu li a:hover,.sophia_after_dark_latest_posts .sad-post-title a:hover,#sad-scrollup:hover,.menu-toggle:hover, #top-navigation ul li a:hover,.sad-search-icon:hover, .entry-meta a:hover, .front-slider-block .banner-title a:hover, .post-info-wrap .entry-meta a:hover, .single .sad-single-related-posts .entry-title a:hover, .breadcrumbs .trail-items li a:hover, .wrap-label i,.has-thumbnail .post-info-wrap .entry-title a:hover,.front-slider-block .post-info-wrap .entry-title a:hover,#top-footer a:hover{ color: ' . esc_attr( $sophia_after_dark_primary_color ) . "}\n";
$output_css .= ".widget_search .search-submit,.widget_search .search-submit:hover,.navigation.pagination .nav-links .page-numbers.current, .navigation.pagination .nav-links a.page-numbers:hover, .error-404.not-found, .sophia_after_dark_social_media a:hover, .custom-header,.widget_tag_cloud .tagcloud a:hover,.widget.widget_tag_cloud a:hover { border-color: ". esc_attr( $sophia_after_dark_primary_color ) ."}\n"; $output_css .= '.widget_search .search-submit,.widget_search .search-submit:hover,.navigation.pagination .nav-links .page-numbers.current, .navigation.pagination .nav-links a.page-numbers:hover, .error-404.not-found, .sophia_after_dark_social_media a:hover, .custom-header,.widget_tag_cloud .tagcloud a:hover,.widget.widget_tag_cloud a:hover { border-color: ' . esc_attr( $sophia_after_dark_primary_color ) . "}\n";
$output_css .= ".front-slider-block .lSAction > a:hover, .top-featured-post-wrap .post-thumbnail .post-number, .post-cats-list a, #site-navigation .menu-item-description, article .post-thumbnail::before, #secondary .widget .widget-title::before, .sad-related-post-title::before, #colophon .widget .widget-title::before, .features-post-title::before, .sad-menu-search .sad-form-wrap .search-form .search-submit,.sad-live-link a,.widget_tag_cloud .tagcloud a:hover,.widget.widget_tag_cloud a:hover { background: ". esc_attr( $sophia_after_dark_primary_color ) ."}\n"; $output_css .= '.front-slider-block .lSAction > a:hover, .top-featured-post-wrap .post-thumbnail .post-number, .post-cats-list a, #site-navigation .menu-item-description, article .post-thumbnail::before, #secondary .widget .widget-title::before, .sad-related-post-title::before, #colophon .widget .widget-title::before, .features-post-title::before, .sad-menu-search .sad-form-wrap .search-form .search-submit,.sad-live-link a,.widget_tag_cloud .tagcloud a:hover,.widget.widget_tag_cloud a:hover { background: ' . esc_attr( $sophia_after_dark_primary_color ) . "}\n";
$output_css .= ".edit-link .post-edit-link,.reply .comment-reply-link,.widget_search .search-submit, .sad-menu-search .sad-form-wrap .search-form .search-submit:hover, article.sticky::before{ background: ". esc_attr( $sophia_after_dark_primary_color ) ."}\n"; $output_css .= '.edit-link .post-edit-link,.reply .comment-reply-link,.widget_search .search-submit, .sad-menu-search .sad-form-wrap .search-form .search-submit:hover, article.sticky::before{ background: ' . esc_attr( $sophia_after_dark_primary_color ) . "}\n";
$output_css .= ".sad-menu-search .sad-form-wrap .search-form .search-field:focus{ outline-color: ". esc_attr( $sophia_after_dark_primary_color ) ."}\n"; $output_css .= '.sad-menu-search .sad-form-wrap .search-form .search-field:focus{ outline-color: ' . esc_attr( $sophia_after_dark_primary_color ) . "}\n";
$slider_bg_image = get_theme_mod( 'sophia_after_dark_slider_bg_image' ); $slider_bg_image = get_theme_mod( 'sophia_after_dark_slider_bg_image' );
if ( !empty( $slider_bg_image ) ) { if ( ! empty( $slider_bg_image ) ) {
$output_css .= ".front-slider-wrapper{background: url(". esc_url( $slider_bg_image ) .") no-repeat fixed center center/cover}\n"; $output_css .= '.front-slider-wrapper{background: url(' . esc_url( $slider_bg_image ) . ") no-repeat fixed center center/cover}\n";
} }
$refine_output_css = sophia_after_dark_css_strip_whitespace( $output_css ); $refine_output_css = sophia_after_dark_css_strip_whitespace( $output_css );
wp_add_inline_style( 'sophia-after-dark-style', $refine_output_css ); wp_add_inline_style( 'sophia-after-dark-style', $refine_output_css );
} }
endif; endif;

View File

@@ -26,31 +26,31 @@ function sophia_after_dark_body_classes( $classes ) {
} }
$sophia_after_dark_site_layout = get_theme_mod( 'sophia_after_dark_site_layout', 'site-layout--wide' ); $sophia_after_dark_site_layout = get_theme_mod( 'sophia_after_dark_site_layout', 'site-layout--wide' );
$classes[] = esc_attr( $sophia_after_dark_site_layout ); $classes[] = esc_attr( $sophia_after_dark_site_layout );
/** /**
* Add classes about style and sidebar layout for archive, post and page * Add classes about style and sidebar layout for archive, post and page
*/ */
if ( is_archive() || is_home() || is_search()) { if ( is_archive() || is_home() || is_search() ) {
$archive_sidebar_layout = get_theme_mod( 'sophia_after_dark_archive_sidebar_layout', 'no-sidebar' ); $archive_sidebar_layout = get_theme_mod( 'sophia_after_dark_archive_sidebar_layout', 'no-sidebar' );
$archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' ); $archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' );
$classes[] = esc_attr( $archive_sidebar_layout ); $classes[] = esc_attr( $archive_sidebar_layout );
$classes[] = esc_attr( $archive_style ); $classes[] = esc_attr( $archive_style );
} elseif ( is_single() ) { } elseif ( is_single() ) {
$single_post_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true ); $single_post_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true );
if ( 'layout--default-sidebar' !== $single_post_sidebar_layout && !empty( $single_post_sidebar_layout ) ) { if ( 'layout--default-sidebar' !== $single_post_sidebar_layout && ! empty( $single_post_sidebar_layout ) ) {
$classes[] = esc_attr( $single_post_sidebar_layout ); $classes[] = esc_attr( $single_post_sidebar_layout );
} else { } else {
$posts_sidebar_layout = get_theme_mod( 'sophia_after_dark_posts_sidebar_layout', 'right-sidebar' ); $posts_sidebar_layout = get_theme_mod( 'sophia_after_dark_posts_sidebar_layout', 'right-sidebar' );
$classes[] = esc_attr( $posts_sidebar_layout ); $classes[] = esc_attr( $posts_sidebar_layout );
} }
} elseif ( is_page() ) { } elseif ( is_page() ) {
$single_page_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true ); $single_page_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true );
if ( 'layout--default-sidebar' !== $single_page_sidebar_layout && !empty( $single_page_sidebar_layout ) ) { if ( 'layout--default-sidebar' !== $single_page_sidebar_layout && ! empty( $single_page_sidebar_layout ) ) {
$classes[] = esc_attr( $single_page_sidebar_layout ); $classes[] = esc_attr( $single_page_sidebar_layout );
} else { } else {
$pages_sidebar_layout = get_theme_mod( 'sophia_after_dark_pages_sidebar_layout', 'right-sidebar' ); $pages_sidebar_layout = get_theme_mod( 'sophia_after_dark_pages_sidebar_layout', 'right-sidebar' );
$classes[] = esc_attr( $pages_sidebar_layout ); $classes[] = esc_attr( $pages_sidebar_layout );
} }
} }
return $classes; return $classes;
@@ -65,7 +65,6 @@ function sophia_after_dark_pingback_header() {
if ( is_singular() && pings_open() ) { if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">'; echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
} }
} }
add_action( 'wp_head', 'sophia_after_dark_pingback_header' ); add_action( 'wp_head', 'sophia_after_dark_pingback_header' );
/*-----------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------*/
@@ -77,35 +76,35 @@ if ( ! function_exists( 'sophia_after_dark_fonts_url' ) ) :
* @return string Bunny fonts URL for the theme. * @return string Bunny fonts URL for the theme.
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_fonts_url() { function sophia_after_dark_fonts_url() {
$fonts_url = ''; $fonts_url = '';
$font_families = array(); $font_families = array();
/* /*
* Translators: If there are characters in your language that are not supported * Translators: If there are characters in your language that are not supported
* byJosefin Sans translate this to 'off'. Do not translate into your own language. * byJosefin Sans translate this to 'off'. Do not translate into your own language.
*/ */
if ( 'off' !== _x( 'on', 'Josefin Sans font: on or off', 'sophia-after-dark' ) ) { if ( 'off' !== _x( 'on', 'Josefin Sans font: on or off', 'sophia-after-dark' ) ) {
$font_families[] = 'Josefin Sans:400,700'; $font_families[] = 'Josefin Sans:400,700';
} }
/* /*
* Translators: If there are characters in your language that are not supported * Translators: If there are characters in your language that are not supported
* by Poppins, translate this to 'off'. Do not translate into your own language. * by Poppins, translate this to 'off'. Do not translate into your own language.
*/ */
if ( 'off' !== _x( 'on', 'Poppins font: on or off', 'sophia-after-dark' ) ) { if ( 'off' !== _x( 'on', 'Poppins font: on or off', 'sophia-after-dark' ) ) {
$font_families[] = 'Poppins:300,400,400i,500,700'; $font_families[] = 'Poppins:300,400,400i,500,700';
} }
if ( $font_families ) { if ( $font_families ) {
$query_args = array( $query_args = array(
'family' => urlencode( implode( '|', $font_families ) ), 'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ), 'subset' => urlencode( 'latin,latin-ext' ),
); );
$fonts_url = add_query_arg( $query_args, 'https://fonts.bunny.net/css' ); $fonts_url = add_query_arg( $query_args, 'https://fonts.bunny.net/css' );
} }
return $fonts_url; return $fonts_url;
} }
endif; endif;
@@ -118,61 +117,88 @@ endif;
add_action( 'admin_enqueue_scripts', 'sophia_after_dark_admin_scripts' ); add_action( 'admin_enqueue_scripts', 'sophia_after_dark_admin_scripts' );
function sophia_after_dark_admin_scripts( $hook ) { function sophia_after_dark_admin_scripts( $hook ) {
global $sophia_after_dark_theme_version; global $sophia_after_dark_theme_version;
if ( 'widgets.php' != $hook && 'customize.php' != $hook && 'edit.php' != $hook && 'post.php' != $hook && 'post-new.php' != $hook ) { if ( 'widgets.php' != $hook && 'customize.php' != $hook && 'edit.php' != $hook && 'post.php' != $hook && 'post-new.php' != $hook ) {
return; return;
} }
wp_enqueue_script( 'jquery-ui-button' ); wp_enqueue_script( 'jquery-ui-button' );
wp_enqueue_script( 'sophia-after-dark--admin-script', get_template_directory_uri() .'/assets/js/sad-admin-scripts.js', array( 'jquery' ), esc_attr( $sophia_after_dark_theme_version ), true ); wp_enqueue_script( 'sophia-after-dark--admin-script', get_template_directory_uri() . '/assets/js/sad-admin-scripts.js', array( 'jquery' ), esc_attr( $sophia_after_dark_theme_version ), true );
wp_enqueue_style( 'sophia-after-dark--admin-style', get_template_directory_uri() . '/assets/css/sad-admin-styles.css', array(), esc_attr( $sophia_after_dark_theme_version ) ); wp_enqueue_style( 'sophia-after-dark--admin-style', get_template_directory_uri() . '/assets/css/sad-admin-styles.css', array(), esc_attr( $sophia_after_dark_theme_version ) );
} }
/*----------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------*/
/** /**
* Enqueue scripts and styles. * Enqueue scripts and styles.
*/ */
function sophia_after_dark_scripts(): void { function sophia_after_dark_scripts(): void {
$v = wp_get_theme()->get('Version'); $v = wp_get_theme()->get( 'Version' );
$dir = get_template_directory_uri(); $dir = get_template_directory_uri();
wp_enqueue_style('sophia-after-dark-fonts', sophia_after_dark_fonts_url(), [], null); wp_enqueue_style( 'sophia-after-dark-fonts', sophia_after_dark_fonts_url(), array(), null );
wp_enqueue_style('lightslider-style', "$dir/assets/library/lightslider/css/lightslider.min.css", [], null); wp_enqueue_style( 'lightslider-style', "$dir/assets/library/lightslider/css/lightslider.min.css", array(), null );
wp_enqueue_style('animate', "$dir/assets/library/animate/animate.min.css", [], '3.5.1'); wp_enqueue_style( 'animate', "$dir/assets/library/animate/animate.min.css", array(), '3.5.1' );
wp_enqueue_style('sophia-after-dark-style', get_stylesheet_uri(), [], $v); wp_enqueue_style( 'sophia-after-dark-style', get_stylesheet_uri(), array(), $v );
wp_enqueue_style('sophia-after-dark-responsive-style', "$dir/assets/css/sad-responsive.css", [], $v); wp_enqueue_style( 'sophia-after-dark-responsive-style', "$dir/assets/css/sad-responsive.css", array(), $v );
wp_enqueue_script('sophia-after-dark-combine-scripts', "$dir/assets/js/sad-combine-scripts.js", ['jquery'], $v, true); wp_enqueue_script( 'sophia-after-dark-combine-scripts', "$dir/assets/js/sad-combine-scripts.js", array( 'jquery' ), $v, true );
wp_enqueue_script('sophia-after-dark-navigation', "$dir/assets/js/navigation.js", [], $v, true); wp_enqueue_script( 'sophia-after-dark-navigation', "$dir/assets/js/navigation.js", array(), $v, true );
wp_enqueue_script('sophia-after-dark-skip-link-focus-fix', "$dir/assets/js/skip-link-focus-fix.js", [], $v, true); wp_enqueue_script( 'sophia-after-dark-skip-link-focus-fix', "$dir/assets/js/skip-link-focus-fix.js", array(), $v, true );
wp_enqueue_script('sophia-after-dark-custom-scripts', "$dir/assets/js/sad-custom-scripts.js", ['jquery'], $v, true); wp_enqueue_script( 'sophia-after-dark-custom-scripts', "$dir/assets/js/sad-custom-scripts.js", array( 'jquery' ), $v, true );
wp_localize_script('sophia-after-dark-custom-scripts', 'sophia_after_darkObject', [ wp_localize_script(
'menu_sticky' => get_theme_mod('sophia_after_dark_enable_sticky_menu', true) ? 'on' : 'off', 'sophia-after-dark-custom-scripts',
'wow_effect' => get_theme_mod('sophia_after_dark_enable_wow_animation', true) ? 'on' : 'off', 'sophia_after_darkObject',
]); array(
'menu_sticky' => get_theme_mod( 'sophia_after_dark_enable_sticky_menu', true ) ? 'on' : 'off',
'wow_effect' => get_theme_mod( 'sophia_after_dark_enable_wow_animation', true ) ? 'on' : 'off',
)
);
if (is_singular() && comments_open() && get_option('thread_comments')) { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script('comment-reply'); wp_enqueue_script( 'comment-reply' );
} }
} }
add_action('wp_enqueue_scripts', 'sophia_after_dark_scripts'); add_action( 'wp_enqueue_scripts', 'sophia_after_dark_scripts' );
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
if ( ! function_exists( 'sophia_after_dark_fork_awesome_social_icon_array' ) ) : if ( ! function_exists( 'sophia_after_dark_fork_awesome_social_icon_array' ) ) :
/** /**
* Define fork awesome social media icons * Define fork awesome social media icons
* *
* @return array(); * @return array();
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_fork_awesome_social_icon_array() { function sophia_after_dark_fork_awesome_social_icon_array() {
return array( return array(
"fa fa-facebook-square","fa fa-facebook-f","fa fa-facebook","fa fa-facebook-official","fa fa-twitter-square","fa fa-twitter","fa fa-yahoo","fa fa-google","fa fa-google-wallet","fa fa-google-plus-circle","fa fa-google-plus-official","fa fa-instagram","fa fa-linkedin-square","fa fa-linkedin","fa fa-pinterest-p","fa fa-pinterest","fa fa-pinterest-square","fa fa-google-plus-square","fa fa-google-plus","fa fa-youtube-square","fa fa-youtube","fa fa-youtube-play","fa fa-vimeo","fa fa-vimeo-square", 'fa fa-facebook-square',
); 'fa fa-facebook-f',
} 'fa fa-facebook',
'fa fa-facebook-official',
'fa fa-twitter-square',
'fa fa-twitter',
'fa fa-yahoo',
'fa fa-google',
'fa fa-google-wallet',
'fa fa-google-plus-circle',
'fa fa-google-plus-official',
'fa fa-instagram',
'fa fa-linkedin-square',
'fa fa-linkedin',
'fa fa-pinterest-p',
'fa fa-pinterest',
'fa fa-pinterest-square',
'fa fa-google-plus-square',
'fa fa-google-plus',
'fa fa-youtube-square',
'fa fa-youtube',
'fa fa-youtube-play',
'fa fa-vimeo',
'fa fa-vimeo-square',
);
}
endif; endif;
@@ -183,7 +209,8 @@ if ( ! function_exists( 'sophia_after_dark_social_media_content' ) ) :
* function to display the social icons * function to display the social icons
*/ */
function sophia_after_dark_social_media_content() { function sophia_after_dark_social_media_content() {
$defaults_icons = json_encode( array( $defaults_icons = json_encode(
array(
array( array(
'social_icon' => 'fa fa-twitter', 'social_icon' => 'fa fa-twitter',
'social_url' => '#', 'social_url' => '#',
@@ -191,30 +218,30 @@ if ( ! function_exists( 'sophia_after_dark_social_media_content' ) ) :
array( array(
'social_icon' => 'fa fa-pinterest', 'social_icon' => 'fa fa-pinterest',
'social_url' => '#', 'social_url' => '#',
) ),
) )
); );
$sophia_after_dark_social_icons = get_theme_mod( 'sophia_after_dark_social_icons', $defaults_icons ); $sophia_after_dark_social_icons = get_theme_mod( 'sophia_after_dark_social_icons', $defaults_icons );
$social_icons = json_decode( $sophia_after_dark_social_icons ); $social_icons = json_decode( $sophia_after_dark_social_icons );
if ( ! empty( $social_icons ) ) { if ( ! empty( $social_icons ) ) {
?> ?>
<ul class="sad-social-icon-wrap"> <ul class="sad-social-icon-wrap">
<?php <?php
foreach ( $social_icons as $social_icon ) { foreach ( $social_icons as $social_icon ) {
if ( ! empty( $social_icon->social_url ) ) { if ( ! empty( $social_icon->social_url ) ) {
?> ?>
<li class="sad-social-icon"> <li class="sad-social-icon">
<a href="<?php echo esc_url( $social_icon->social_url ); ?>" target="_blank"> <a href="<?php echo esc_url( $social_icon->social_url ); ?>" target="_blank">
<i class="<?php echo esc_attr( $social_icon->social_icon ); ?>"></i> <i class="<?php echo esc_attr( $social_icon->social_icon ); ?>"></i>
</a> </a>
</li> </li>
<?php <?php
}
} }
}
?> ?>
</ul> </ul>
<?php <?php
} }
} }
@@ -223,33 +250,33 @@ endif;
if ( ! function_exists( 'sophia_after_dark_hover_color' ) ) : if ( ! function_exists( 'sophia_after_dark_hover_color' ) ) :
/** /**
* Generate darker color * Generate darker color
* Source: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php * Source: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php
* *
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_hover_color( $hex, $steps ) { function sophia_after_dark_hover_color( $hex, $steps ) {
// Steps should be between -255 and 255. Negative = darker, positive = lighter // Steps should be between -255 and 255. Negative = darker, positive = lighter
$steps = max( -255, min( 255, $steps ) ); $steps = max( -255, min( 255, $steps ) );
// Normalize into a six character long hex string // Normalize into a six character long hex string
$hex = str_replace( '#', '', $hex ); $hex = str_replace( '#', '', $hex );
if ( strlen( $hex ) == 3) { if ( strlen( $hex ) == 3 ) {
$hex = str_repeat( substr( $hex,0,1 ), 2 ).str_repeat( substr( $hex, 1, 1 ), 2 ).str_repeat( substr( $hex,2,1 ), 2 ); $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
} }
// Split into three parts: R, G and B // Split into three parts: R, G and B
$color_parts = str_split( $hex, 2 ); $color_parts = str_split( $hex, 2 );
$return = '#'; $return = '#';
foreach ( $color_parts as $color ) { foreach ( $color_parts as $color ) {
$color = hexdec( $color ); // Convert to decimal $color = hexdec( $color ); // Convert to decimal
$color = max( 0, min( 255, $color + $steps ) ); // Adjust color $color = max( 0, min( 255, $color + $steps ) ); // Adjust color
$return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code
} }
return $return; return $return;
} }
endif; endif;
@@ -262,12 +289,12 @@ if ( ! function_exists( 'sophia_after_dark_select_categories_list' ) ) :
* @return $sophia_after_dark_categories_list in array * @return $sophia_after_dark_categories_list in array
*/ */
function sophia_after_dark_select_categories_list() { function sophia_after_dark_select_categories_list() {
$sophia_after_dark_get_categories = get_categories( array( 'hide_empty' => 0 ) ); $sophia_after_dark_get_categories = get_categories( array( 'hide_empty' => 0 ) );
$sophia_after_dark_categories_list[''] = __( 'Select Category', 'sophia-after-dark' ); $sophia_after_dark_categories_list[''] = __( 'Select Category', 'sophia-after-dark' );
foreach ( $sophia_after_dark_get_categories as $category ) { foreach ( $sophia_after_dark_get_categories as $category ) {
$sophia_after_dark_categories_list[esc_attr( $category->slug )] = esc_html( $category->cat_name ); $sophia_after_dark_categories_list[ esc_attr( $category->slug ) ] = esc_html( $category->cat_name );
} }
return $sophia_after_dark_categories_list; return $sophia_after_dark_categories_list;
} }
endif; endif;
@@ -306,33 +333,33 @@ endif;
/*----------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------*/
if ( ! function_exists( 'sophia_after_dark_inner_header_bg_image' ) ) : if ( ! function_exists( 'sophia_after_dark_inner_header_bg_image' ) ) :
/** /**
* Background image for inner page header * Background image for inner page header
* *
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_inner_header_bg_image( $input ) { function sophia_after_dark_inner_header_bg_image( $input ) {
$image_attr = array(); $image_attr = array();
if ( empty( $image_attr ) ) { if ( empty( $image_attr ) ) {
// Fetch from Custom Header Image. // Fetch from Custom Header Image.
$image = get_header_image(); $image = get_header_image();
if ( ! empty( $image ) ) { if ( ! empty( $image ) ) {
$image_attr['url'] = $image; $image_attr['url'] = $image;
$image_attr['width'] = get_custom_header()->width; $image_attr['width'] = get_custom_header()->width;
$image_attr['height'] = get_custom_header()->height; $image_attr['height'] = get_custom_header()->height;
} }
} }
if ( ! empty( $image_attr ) ) { if ( ! empty( $image_attr ) ) {
$input .= 'background-image:url(' . esc_url( $image_attr['url'] ) . ');'; $input .= 'background-image:url(' . esc_url( $image_attr['url'] ) . ');';
$input .= 'background-size:cover;'; $input .= 'background-size:cover;';
} }
return $input; return $input;
} }
endif; endif;
add_filter( 'sophia_after_dark_inner_header_style_attribute', 'sophia_after_dark_inner_header_bg_image' ); add_filter( 'sophia_after_dark_inner_header_style_attribute', 'sophia_after_dark_inner_header_bg_image' );
@@ -344,32 +371,31 @@ if ( ! function_exists( 'sophia_after_dark_css_strip_whitespace' ) ) :
* *
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_css_strip_whitespace( $css ) {
$replace = array(
'#/\*.*?\*/#s' => '', // Strip C style comments.
'#\s\s+#' => ' ', // Strip excess whitespace.
);
$search = array_keys( $replace );
$css = preg_replace( $search, $replace, $css );
function sophia_after_dark_css_strip_whitespace( $css ){ $replace = array(
$replace = array( ': ' => ':',
"#/\*.*?\*/#s" => "", // Strip C style comments. '; ' => ';',
"#\s\s+#" => " ", // Strip excess whitespace. ' {' => '{',
); ' }' => '}',
$search = array_keys( $replace ); ', ' => ',',
$css = preg_replace( $search, $replace, $css ); '{ ' => '{',
';}' => '}', // Strip optional semicolons.
",\n" => ',', // Don't wrap multiple selectors.
"\n}" => '}', // Don't wrap closing braces.
'} ' => "}\n", // Put each rule on it's own line.
);
$search = array_keys( $replace );
$css = str_replace( $search, $replace, $css );
$replace = array( return trim( $css );
": " => ":", }
"; " => ";",
" {" => "{",
" }" => "}",
", " => ",",
"{ " => "{",
";}" => "}", // Strip optional semicolons.
",\n" => ",", // Don't wrap multiple selectors.
"\n}" => "}", // Don't wrap closing braces.
"} " => "}\n", // Put each rule on it's own line.
);
$search = array_keys( $replace );
$css = str_replace( $search, $replace, $css );
return trim( $css );
}
endif; endif;
@@ -377,18 +403,17 @@ endif;
/** /**
* Archive title prefix * Archive title prefix
*
*/ */
$archive_title_prefix_option = get_theme_mod( 'sophia_after_dark_enable_archive_title_prefix', true ); $archive_title_prefix_option = get_theme_mod( 'sophia_after_dark_enable_archive_title_prefix', true );
if ( false === $archive_title_prefix_option ) { if ( false === $archive_title_prefix_option ) {
add_filter( 'get_the_archive_title', 'sophia_after_dark_archive_title_prefix' ); add_filter( 'get_the_archive_title', 'sophia_after_dark_archive_title_prefix' );
} }
if ( ! function_exists( 'sophia_after_dark_archive_title_prefix' ) ) : if ( ! function_exists( 'sophia_after_dark_archive_title_prefix' ) ) :
function sophia_after_dark_archive_title_prefix( $title ) { function sophia_after_dark_archive_title_prefix( $title ) {
return preg_replace( '/^\w+: /', '', $title ); return preg_replace( '/^\w+: /', '', $title );
} }
endif; endif;

View File

@@ -20,7 +20,8 @@ if ( ! function_exists( 'sophia_after_dark_posted_on' ) ) :
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
} }
$time_string = sprintf( $time_string, $time_string = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ), esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() ), esc_html( get_the_date() ),
esc_attr( get_the_modified_date( DATE_W3C ) ), esc_attr( get_the_modified_date( DATE_W3C ) ),
@@ -33,7 +34,6 @@ if ( ! function_exists( 'sophia_after_dark_posted_on' ) ) :
); );
echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK. echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.
} }
endif; endif;
@@ -47,8 +47,7 @@ if ( ! function_exists( 'sophia_after_dark_posted_by' ) ) :
*/ */
function sophia_after_dark_posted_by() { function sophia_after_dark_posted_by() {
echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="'. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) .'">'. esc_html( get_the_author() ) .'</a></span></span>'; // WPCS: XSS OK. echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span></span>'; // WPCS: XSS OK.
} }
endif; endif;
@@ -103,8 +102,8 @@ if ( ! function_exists( 'sophia_after_dark_entry_footer' ) ) :
if ( 'post' === get_post_type() && ! is_single() ) { if ( 'post' === get_post_type() && ! is_single() ) {
$sophia_after_dark_archive_read_more = get_theme_mod( 'sophia_after_dark_archive_read_more', __( 'Discover', 'sophia-after-dark' ) ); $sophia_after_dark_archive_read_more = get_theme_mod( 'sophia_after_dark_archive_read_more', __( 'Discover', 'sophia-after-dark' ) );
?> ?>
<?php <?php
} }
edit_post_link( edit_post_link(
@@ -179,9 +178,9 @@ if ( ! function_exists( 'sophia_after_dark_post_thumbnail' ) ) :
global $wp_query; global $wp_query;
$current_post = $wp_query->current_post; $current_post = $wp_query->current_post;
$thumbnail_size = 'post-thumbnail'; $thumbnail_size = 'post-thumbnail';
$archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' ); $archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' );
$sidebar_layout = sophia_after_dark_is_sidebar_layout(); $sidebar_layout = sophia_after_dark_is_sidebar_layout();
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return; return;
@@ -190,12 +189,12 @@ if ( ! function_exists( 'sophia_after_dark_post_thumbnail' ) ) :
// define image size in various section // define image size in various section
if ( 'sad-archive--masonry-style' === $archive_style ) { if ( 'sad-archive--masonry-style' === $archive_style ) {
$thumbnail_size = 'sophia-after-dark-post-auto'; $thumbnail_size = 'sophia-after-dark-post-auto';
}elseif ( 'sad-archive--block-grid-style' === $archive_style ) { } elseif ( 'sad-archive--block-grid-style' === $archive_style ) {
$thumbnail_size = 'sophia-after-dark-full-width'; $thumbnail_size = 'sophia-after-dark-full-width';
} }
if ( is_singular() ) : if ( is_singular() ) :
?> ?>
<div class="post-thumbnail"> <div class="post-thumbnail">
<?php the_post_thumbnail( 'sophia-after-dark-full-width' ); ?> <?php the_post_thumbnail( 'sophia-after-dark-full-width' ); ?>
@@ -205,15 +204,20 @@ if ( ! function_exists( 'sophia_after_dark_post_thumbnail' ) ) :
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1"> <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
<?php <?php
the_post_thumbnail( $thumbnail_size, array( the_post_thumbnail(
'alt' => the_title_attribute( array( $thumbnail_size,
'echo' => false, array(
) ), 'alt' => the_title_attribute(
) ); array(
'echo' => false,
)
),
)
);
?> ?>
</a> </a>
<?php <?php
endif; // End is_singular(). endif; // End is_singular().
} }
@@ -228,22 +232,23 @@ if ( ! function_exists( 'sophia_after_dark_article_categories_list' ) ) :
*/ */
function sophia_after_dark_article_categories_list() { function sophia_after_dark_article_categories_list() {
global $post; global $post;
$post_id = $post->ID; $post_id = $post->ID;
$categories_list = get_the_category( $post_id ); $categories_list = get_the_category( $post_id );
if ( !empty( $categories_list ) ) { if ( ! empty( $categories_list ) ) {
?> ?>
<div class="post-cats-list"> <div class="post-cats-list">
<?php <?php
foreach ( $categories_list as $cat_data ) { foreach ( $categories_list as $cat_data ) {
$cat_name = $cat_data->name; $cat_name = $cat_data->name;
$cat_id = $cat_data->term_id; $cat_id = $cat_data->term_id;
$cat_link = get_category_link( $cat_id ); $cat_link = get_category_link( $cat_id );
?> ?>
<span class="category-button cbd-cat-<?php echo esc_attr( $cat_id ); ?>"><a href="<?php echo esc_url( $cat_link ); ?>"><?php echo esc_html( $cat_name ); ?></a></span> <span class="category-button cbd-cat-<?php echo esc_attr( $cat_id ); ?>"><a href="<?php echo esc_url( $cat_link ); ?>"><?php echo esc_html( $cat_name ); ?></a></span>
<?php <?php
} }
?> ?>
</div><?php </div>
<?php
} }
} }
@@ -254,10 +259,10 @@ endif;
* Add cat id in menu class * Add cat id in menu class
*/ */
function sophia_after_dark_category_nav_class( $classes, $item ) { function sophia_after_dark_category_nav_class( $classes, $item ) {
if ( 'category' == $item->object ){ if ( 'category' == $item->object ) {
$category = get_category( $item->object_id ); $category = get_category( $item->object_id );
$classes[] = 'cbd-cat-' . $category->term_id; $classes[] = 'cbd-cat-' . $category->term_id;
} }
return $classes; return $classes;
} }
add_filter( 'nav_menu_css_class', 'sophia_after_dark_category_nav_class', 10, 2 ); add_filter( 'nav_menu_css_class', 'sophia_after_dark_category_nav_class', 10, 2 );

View File

@@ -11,158 +11,158 @@
class sophia_after_dark_Author_Info extends WP_widget { class sophia_after_dark_Author_Info extends WP_widget {
/** /**
* Register widget with WordPress. * Register widget with WordPress.
*/ */
public function __construct() { public function __construct() {
$widget_ops = array( $widget_ops = array(
'classname' => 'sophia_after_dark_author_info', 'classname' => 'sophia_after_dark_author_info',
'description' => __( 'Select the user to display the author info.', 'sophia-after-dark' ), 'description' => __( 'Select the user to display the author info.', 'sophia-after-dark' ),
'customize_selective_refresh' => true, 'customize_selective_refresh' => true,
); );
parent::__construct( 'sophia_after_dark_author_info', __( 'MT: Author Info', 'sophia-after-dark' ), $widget_ops ); parent::__construct( 'sophia_after_dark_author_info', __( 'MT: Author Info', 'sophia-after-dark' ), $widget_ops );
} }
/** /**
* Helper function that holds widget fields * Helper function that holds widget fields
* Array is used in update and form functions * Array is used in update and form functions
*/ */
private function widget_fields() { private function widget_fields() {
$fields = array( $fields = array(
'widget_title' => array( 'widget_title' => array(
'sophia_after_dark_widgets_name' => 'widget_title', 'sophia_after_dark_widgets_name' => 'widget_title',
'sophia_after_dark_widgets_title' => __( 'Widget title', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Widget title', 'sophia-after-dark' ),
'sophia_after_dark_widgets_field_type' => 'text' 'sophia_after_dark_widgets_field_type' => 'text',
), ),
'user_name' => array( 'user_name' => array(
'sophia_after_dark_widgets_name' => 'user_name', 'sophia_after_dark_widgets_name' => 'user_name',
'sophia_after_dark_widgets_title' => __( 'User Name', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'User Name', 'sophia-after-dark' ),
'sophia_after_dark_widgets_field_type' => 'text' 'sophia_after_dark_widgets_field_type' => 'text',
), ),
'user_id' => array( 'user_id' => array(
'sophia_after_dark_widgets_name' => 'user_id', 'sophia_after_dark_widgets_name' => 'user_id',
'sophia_after_dark_widgets_title' => __( 'Select Author', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Select Author', 'sophia-after-dark' ),
'sophia_after_dark_widgets_default' => '', 'sophia_after_dark_widgets_default' => '',
'sophia_after_dark_widgets_field_type' => 'user_dropdown' 'sophia_after_dark_widgets_field_type' => 'user_dropdown',
), ),
'user_thumb' => array( 'user_thumb' => array(
'sophia_after_dark_widgets_name' => 'user_thumb', 'sophia_after_dark_widgets_name' => 'user_thumb',
'sophia_after_dark_widgets_title' => __( 'Author Image', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Author Image', 'sophia-after-dark' ),
'sophia_after_dark_widgets_field_type' => 'upload' 'sophia_after_dark_widgets_field_type' => 'upload',
), ),
); );
return $fields; return $fields;
} }
/** /**
* Front-end display of widget. * Front-end display of widget.
* *
* @see WP_Widget::widget() * @see WP_Widget::widget()
* *
* @param array $args Widget arguments. * @param array $args Widget arguments.
* @param array $instance Saved values from database. * @param array $instance Saved values from database.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
extract( $args ); extract( $args );
if ( empty( $instance ) ) { if ( empty( $instance ) ) {
return ; return;
} }
$sophia_after_dark_widget_title = empty( $instance['widget_title'] ) ? '' : $instance['widget_title']; $sophia_after_dark_widget_title = empty( $instance['widget_title'] ) ? '' : $instance['widget_title'];
$sophia_after_dark_user_name = empty( $instance['user_name'] ) ? '' : $instance['user_name']; $sophia_after_dark_user_name = empty( $instance['user_name'] ) ? '' : $instance['user_name'];
$sophia_after_dark_user_id = empty( $instance['user_id'] ) ? '' : $instance['user_id']; $sophia_after_dark_user_id = empty( $instance['user_id'] ) ? '' : $instance['user_id'];
$sophia_after_dark_user_image = empty( $instance['user_thumb'] ) ? '' : $instance['user_thumb']; $sophia_after_dark_user_image = empty( $instance['user_thumb'] ) ? '' : $instance['user_thumb'];
echo $before_widget; echo $before_widget;
?> ?>
<div class="sad-author-info-wrapper"> <div class="sad-author-info-wrapper">
<?php <?php
if ( ! empty( $sophia_after_dark_widget_title ) ) { if ( ! empty( $sophia_after_dark_widget_title ) ) {
echo $before_title . esc_html( $sophia_after_dark_widget_title ) . $after_title; echo $before_title . esc_html( $sophia_after_dark_widget_title ) . $after_title;
} }
?> ?>
<div class="author-bio-wrap"> <div class="author-bio-wrap">
<div class="author-avatar"> <div class="author-avatar">
<?php <?php
if ( ! empty( $sophia_after_dark_user_image ) ) { if ( ! empty( $sophia_after_dark_user_image ) ) {
echo '<img src="'. esc_url( $sophia_after_dark_user_image ) .'" />'; echo '<img src="' . esc_url( $sophia_after_dark_user_image ) . '" />';
} else { } else {
echo get_avatar( $sophia_after_dark_user_id, '132' ); echo get_avatar( $sophia_after_dark_user_id, '132' );
} }
?> ?>
</div> </div>
<h3 class="author-name"> <h3 class="author-name">
<?php <?php
if ( empty( $sophia_after_dark_user_name ) ) { if ( empty( $sophia_after_dark_user_name ) ) {
echo wp_kses_post( get_the_author_meta( 'nickname', $sophia_after_dark_user_id ) ); echo wp_kses_post( get_the_author_meta( 'nickname', $sophia_after_dark_user_id ) );
} else { } else {
echo esc_html( $sophia_after_dark_user_name ); echo esc_html( $sophia_after_dark_user_name );
} }
?> ?>
</h3> </h3>
<div class="author-description"><?php echo wp_kses_post( wpautop( get_the_author_meta( 'description', $sophia_after_dark_user_id ) ) ); ?></div> <div class="author-description"><?php echo wp_kses_post( wpautop( get_the_author_meta( 'description', $sophia_after_dark_user_id ) ) ); ?></div>
<div class="author-social"> <div class="author-social">
<?php sophia_after_dark_social_media_content(); ?> <?php sophia_after_dark_social_media_content(); ?>
</div> </div>
</div> </div>
</div> </div>
<?php <?php
echo $after_widget; echo $after_widget;
} }
/** /**
* Sanitize widget form values as they are saved. * Sanitize widget form values as they are saved.
* *
* @see WP_Widget::update() * @see WP_Widget::update()
* *
* @param array $new_instance Values just sent to be saved. * @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database. * @param array $old_instance Previously saved values from database.
* *
* @uses sophia_after_dark_widgets_updated_field_value() defined in sad-widget-fields.php * @uses sophia_after_dark_widgets_updated_field_value() defined in sad-widget-fields.php
* *
* @return array Updated safe values to be saved. * @return array Updated safe values to be saved.
*/ */
public function update( $new_instance, $old_instance ) { public function update( $new_instance, $old_instance ) {
$instance = $old_instance; $instance = $old_instance;
$widget_fields = $this->widget_fields(); $widget_fields = $this->widget_fields();
// Loop through fields // Loop through fields
foreach ( $widget_fields as $widget_field ) { foreach ( $widget_fields as $widget_field ) {
extract( $widget_field ); extract( $widget_field );
// Use helper function to get updated field values // Use helper function to get updated field values
$instance[$sophia_after_dark_widgets_name] = sophia_after_dark_widgets_updated_field_value( $widget_field, $new_instance[$sophia_after_dark_widgets_name] ); $instance[ $sophia_after_dark_widgets_name ] = sophia_after_dark_widgets_updated_field_value( $widget_field, $new_instance[ $sophia_after_dark_widgets_name ] );
} }
return $instance; return $instance;
} }
/** /**
* Back-end widget form. * Back-end widget form.
* *
* @see WP_Widget::form() * @see WP_Widget::form()
* *
* @param array $instance Previously saved values from database. * @param array $instance Previously saved values from database.
* *
* @uses sophia_after_dark_widgets_show_widget_field() defined in sad-widget-fields.php * @uses sophia_after_dark_widgets_show_widget_field() defined in sad-widget-fields.php
*/ */
public function form( $instance ) { public function form( $instance ) {
$widget_fields = $this->widget_fields(); $widget_fields = $this->widget_fields();
// Loop through fields // Loop through fields
foreach ( $widget_fields as $widget_field ) { foreach ( $widget_fields as $widget_field ) {
// Make array elements available as variables // Make array elements available as variables
extract( $widget_field ); extract( $widget_field );
$sophia_after_dark_widgets_field_value = !empty( $instance[$sophia_after_dark_widgets_name] ) ? wp_kses_post( $instance[$sophia_after_dark_widgets_name] ) : ''; $sophia_after_dark_widgets_field_value = ! empty( $instance[ $sophia_after_dark_widgets_name ] ) ? wp_kses_post( $instance[ $sophia_after_dark_widgets_name ] ) : '';
sophia_after_dark_widgets_show_widget_field( $this, $widget_field, $sophia_after_dark_widgets_field_value ); sophia_after_dark_widgets_show_widget_field( $this, $widget_field, $sophia_after_dark_widgets_field_value );
} }
} }
} }

View File

@@ -11,169 +11,169 @@
class sophia_after_dark_Latest_Posts extends WP_widget { class sophia_after_dark_Latest_Posts extends WP_widget {
/** /**
* Register widget with WordPress. * Register widget with WordPress.
*/ */
public function __construct() { public function __construct() {
$widget_ops = array( $widget_ops = array(
'classname' => 'sophia_after_dark_latest_posts', 'classname' => 'sophia_after_dark_latest_posts',
'description' => __( 'A widget to display the latest posts with thumbnail.', 'sophia-after-dark' ), 'description' => __( 'A widget to display the latest posts with thumbnail.', 'sophia-after-dark' ),
'customize_selective_refresh' => true, 'customize_selective_refresh' => true,
); );
parent::__construct( 'sophia_after_dark_latest_posts', __( 'MT: Latest Posts', 'sophia-after-dark' ), $widget_ops ); parent::__construct( 'sophia_after_dark_latest_posts', __( 'MT: Latest Posts', 'sophia-after-dark' ), $widget_ops );
} }
/** /**
* Helper function that holds widget fields * Helper function that holds widget fields
* Array is used in update and form functions * Array is used in update and form functions
*/ */
private function widget_fields() { private function widget_fields() {
$fields = array( $fields = array(
'widget_title' => array( 'widget_title' => array(
'sophia_after_dark_widgets_name' => 'widget_title', 'sophia_after_dark_widgets_name' => 'widget_title',
'sophia_after_dark_widgets_title' => __( 'Widget title', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Widget title', 'sophia-after-dark' ),
'sophia_after_dark_widgets_field_type' => 'text' 'sophia_after_dark_widgets_field_type' => 'text',
), ),
'widget_post_order' => array( 'widget_post_order' => array(
'sophia_after_dark_widgets_name' => 'widget_post_order', 'sophia_after_dark_widgets_name' => 'widget_post_order',
'sophia_after_dark_widgets_title' => __( 'Post Order', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Post Order', 'sophia-after-dark' ),
'sophia_after_dark_widgets_default' => 'default', 'sophia_after_dark_widgets_default' => 'default',
'sophia_after_dark_widgets_field_type' => 'select', 'sophia_after_dark_widgets_field_type' => 'select',
'sophia_after_dark_widgets_field_options' => array( 'sophia_after_dark_widgets_field_options' => array(
'default' => __( 'Default Order', 'sophia-after-dark' ), 'default' => __( 'Default Order', 'sophia-after-dark' ),
'random' => __( 'Random Order', 'sophia-after-dark' ), 'random' => __( 'Random Order', 'sophia-after-dark' ),
) ),
), ),
'widget_post_count' => array( 'widget_post_count' => array(
'sophia_after_dark_widgets_name' => 'widget_post_count', 'sophia_after_dark_widgets_name' => 'widget_post_count',
'sophia_after_dark_widgets_title' => __( 'Post Count', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Post Count', 'sophia-after-dark' ),
'sophia_after_dark_widgets_default' => '5', 'sophia_after_dark_widgets_default' => '5',
'sophia_after_dark_widgets_field_type' => 'number' 'sophia_after_dark_widgets_field_type' => 'number',
) ),
); );
return $fields; return $fields;
} }
/** /**
* Front-end display of widget. * Front-end display of widget.
* *
* @see WP_Widget::widget() * @see WP_Widget::widget()
* *
* @param array $args Widget arguments. * @param array $args Widget arguments.
* @param array $instance Saved values from database. * @param array $instance Saved values from database.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
extract( $args ); extract( $args );
if ( empty( $instance ) ) { if ( empty( $instance ) ) {
return ; return;
} }
$sophia_after_dark_widget_title = empty( $instance['widget_title'] ) ? '' : $instance['widget_title']; $sophia_after_dark_widget_title = empty( $instance['widget_title'] ) ? '' : $instance['widget_title'];
$sophia_after_dark_post_order = empty( $instance['widget_post_order'] ) ? 'default' : $instance['widget_post_order']; $sophia_after_dark_post_order = empty( $instance['widget_post_order'] ) ? 'default' : $instance['widget_post_order'];
$sophia_after_dark_post_count = empty( $instance['widget_post_count'] ) ? '5' : $instance['widget_post_count']; $sophia_after_dark_post_count = empty( $instance['widget_post_count'] ) ? '5' : $instance['widget_post_count'];
echo $before_widget; echo $before_widget;
?> ?>
<div class="sad-latest-posts-wrapper"> <div class="sad-latest-posts-wrapper">
<?php <?php
if ( !empty( $sophia_after_dark_widget_title ) ) { if ( ! empty( $sophia_after_dark_widget_title ) ) {
echo $before_title . esc_html( $sophia_after_dark_widget_title ) . $after_title; echo $before_title . esc_html( $sophia_after_dark_widget_title ) . $after_title;
} }
?> ?>
<div class="sad-posts-content-wrapper"> <div class="sad-posts-content-wrapper">
<?php <?php
$sophia_after_dark_posts_args = array( $sophia_after_dark_posts_args = array(
'posts_per_page' => absint( $sophia_after_dark_post_count ), 'posts_per_page' => absint( $sophia_after_dark_post_count ),
'ignore_sticky_posts' => 1, 'ignore_sticky_posts' => 1,
); );
if ( 'random' === $sophia_after_dark_post_order ) { if ( 'random' === $sophia_after_dark_post_order ) {
$sophia_after_dark_posts_args['orderby'] = 'rand'; $sophia_after_dark_posts_args['orderby'] = 'rand';
} }
$sophia_after_dark_posts_query = new WP_Query( $sophia_after_dark_posts_args ); $sophia_after_dark_posts_query = new WP_Query( $sophia_after_dark_posts_args );
if ( $sophia_after_dark_posts_query->have_posts() ) { if ( $sophia_after_dark_posts_query->have_posts() ) {
while ( $sophia_after_dark_posts_query->have_posts() ) { while ( $sophia_after_dark_posts_query->have_posts() ) {
$sophia_after_dark_posts_query->the_post(); $sophia_after_dark_posts_query->the_post();
?> ?>
<div class="sad-single-post-wrap"> <div class="sad-single-post-wrap">
<?php if ( has_post_thumbnail() ) { ?> <?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<figure><div class="sad-post-thumb"><?php the_post_thumbnail( 'thumbnail' ); ?></div></figure> <figure><div class="sad-post-thumb"><?php the_post_thumbnail( 'thumbnail' ); ?></div></figure>
</a> </a>
<?php } ?> <?php } ?>
<div class="sad-post-content"> <div class="sad-post-content">
<h5 class="sad-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5> <h5 class="sad-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
<div class="entry-cat"> <div class="entry-cat">
<?php <?php
sophia_after_dark_posted_on(); sophia_after_dark_posted_on();
sophia_after_dark_posted_by(); sophia_after_dark_posted_by();
?> ?>
</div> </div>
<?php sophia_after_dark_widget_entry_footer(); ?> <?php sophia_after_dark_widget_entry_footer(); ?>
</div> </div>
</div> </div>
<?php <?php
} }
} }
?> ?>
</div> </div>
</div> </div>
<?php <?php
echo $after_widget; echo $after_widget;
} }
/** /**
* Sanitize widget form values as they are saved. * Sanitize widget form values as they are saved.
* *
* @see WP_Widget::update() * @see WP_Widget::update()
* *
* @param array $new_instance Values just sent to be saved. * @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database. * @param array $old_instance Previously saved values from database.
* *
* @uses sophia_after_dark_widgets_updated_field_value() defined in sad-widget-fields.php * @uses sophia_after_dark_widgets_updated_field_value() defined in sad-widget-fields.php
* *
* @return array Updated safe values to be saved. * @return array Updated safe values to be saved.
*/ */
public function update( $new_instance, $old_instance ) { public function update( $new_instance, $old_instance ) {
$instance = $old_instance; $instance = $old_instance;
$widget_fields = $this->widget_fields(); $widget_fields = $this->widget_fields();
// Loop through fields // Loop through fields
foreach ( $widget_fields as $widget_field ) { foreach ( $widget_fields as $widget_field ) {
extract( $widget_field ); extract( $widget_field );
// Use helper function to get updated field values // Use helper function to get updated field values
$instance[$sophia_after_dark_widgets_name] = sophia_after_dark_widgets_updated_field_value( $widget_field, $new_instance[$sophia_after_dark_widgets_name] ); $instance[ $sophia_after_dark_widgets_name ] = sophia_after_dark_widgets_updated_field_value( $widget_field, $new_instance[ $sophia_after_dark_widgets_name ] );
} }
return $instance; return $instance;
} }
/** /**
* Back-end widget form. * Back-end widget form.
* *
* @see WP_Widget::form() * @see WP_Widget::form()
* *
* @param array $instance Previously saved values from database. * @param array $instance Previously saved values from database.
* *
* @uses sophia_after_dark_widgets_show_widget_field() defined in sad-widget-fields.php * @uses sophia_after_dark_widgets_show_widget_field() defined in sad-widget-fields.php
*/ */
public function form( $instance ) { public function form( $instance ) {
$widget_fields = $this->widget_fields(); $widget_fields = $this->widget_fields();
// Loop through fields // Loop through fields
foreach ( $widget_fields as $widget_field ) { foreach ( $widget_fields as $widget_field ) {
// Make array elements available as variables // Make array elements available as variables
extract( $widget_field ); extract( $widget_field );
$sophia_after_dark_widgets_field_value = !empty( $instance[$sophia_after_dark_widgets_name] ) ? wp_kses_post( $instance[$sophia_after_dark_widgets_name] ) : ''; $sophia_after_dark_widgets_field_value = ! empty( $instance[ $sophia_after_dark_widgets_name ] ) ? wp_kses_post( $instance[ $sophia_after_dark_widgets_name ] ) : '';
sophia_after_dark_widgets_show_widget_field( $this, $widget_field, $sophia_after_dark_widgets_field_value ); sophia_after_dark_widgets_show_widget_field( $this, $widget_field, $sophia_after_dark_widgets_field_value );
} }
} }
} }

View File

@@ -11,118 +11,118 @@
class sophia_after_dark_Social_Media extends WP_widget { class sophia_after_dark_Social_Media extends WP_widget {
/** /**
* Register widget with WordPress. * Register widget with WordPress.
*/ */
public function __construct() { public function __construct() {
$widget_ops = array( $widget_ops = array(
'classname' => 'sophia_after_dark_social_media', 'classname' => 'sophia_after_dark_social_media',
'description' => __( 'A widget shows the social media icons.', 'sophia-after-dark' ), 'description' => __( 'A widget shows the social media icons.', 'sophia-after-dark' ),
'customize_selective_refresh' => true, 'customize_selective_refresh' => true,
); );
parent::__construct( 'sophia_after_dark_social_media', __( 'MT: Social Media', 'sophia-after-dark' ), $widget_ops ); parent::__construct( 'sophia_after_dark_social_media', __( 'MT: Social Media', 'sophia-after-dark' ), $widget_ops );
} }
/** /**
* Helper function that holds widget fields * Helper function that holds widget fields
* Array is used in update and form functions * Array is used in update and form functions
*/ */
private function widget_fields() { private function widget_fields() {
$fields = array( $fields = array(
'widget_title' => array( 'widget_title' => array(
'sophia_after_dark_widgets_name' => 'widget_title', 'sophia_after_dark_widgets_name' => 'widget_title',
'sophia_after_dark_widgets_title' => __( 'Widget title', 'sophia-after-dark' ), 'sophia_after_dark_widgets_title' => __( 'Widget title', 'sophia-after-dark' ),
'sophia_after_dark_widgets_field_type' => 'text' 'sophia_after_dark_widgets_field_type' => 'text',
) ),
); );
return $fields; return $fields;
} }
/** /**
* Front-end display of widget. * Front-end display of widget.
* *
* @see WP_Widget::widget() * @see WP_Widget::widget()
* *
* @param array $args Widget arguments. * @param array $args Widget arguments.
* @param array $instance Saved values from database. * @param array $instance Saved values from database.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
extract( $args ); extract( $args );
if ( empty( $instance ) ) { if ( empty( $instance ) ) {
return ; return;
} }
$sophia_after_dark_widget_title = empty( $instance['widget_title'] ) ? '' : $instance['widget_title']; $sophia_after_dark_widget_title = empty( $instance['widget_title'] ) ? '' : $instance['widget_title'];
$get_social_media_icons = get_theme_mod( 'social_media_icons', '' ); $get_social_media_icons = get_theme_mod( 'social_media_icons', '' );
$get_decode_social_media = json_decode( $get_social_media_icons ); $get_decode_social_media = json_decode( $get_social_media_icons );
echo $before_widget; echo $before_widget;
?> ?>
<div class="sad-aside-social-wrapper"> <div class="sad-aside-social-wrapper">
<?php <?php
if ( ! empty( $sophia_after_dark_widget_title ) ) { if ( ! empty( $sophia_after_dark_widget_title ) ) {
echo $before_title . esc_html( $sophia_after_dark_widget_title ) . $after_title; echo $before_title . esc_html( $sophia_after_dark_widget_title ) . $after_title;
} }
?> ?>
<div class="sad-social-icons-wrapper"> <div class="sad-social-icons-wrapper">
<?php sophia_after_dark_social_media_content(); ?> <?php sophia_after_dark_social_media_content(); ?>
</div> </div>
</div> </div>
<?php <?php
echo $after_widget; echo $after_widget;
} }
/** /**
* Sanitize widget form values as they are saved. * Sanitize widget form values as they are saved.
* *
* @see WP_Widget::update() * @see WP_Widget::update()
* *
* @param array $new_instance Values just sent to be saved. * @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database. * @param array $old_instance Previously saved values from database.
* *
* @uses sophia_after_dark_widgets_updated_field_value() defined in sad-widget-fields.php * @uses sophia_after_dark_widgets_updated_field_value() defined in sad-widget-fields.php
* *
* @return array Updated safe values to be saved. * @return array Updated safe values to be saved.
*/ */
public function update( $new_instance, $old_instance ) { public function update( $new_instance, $old_instance ) {
$instance = $old_instance; $instance = $old_instance;
$widget_fields = $this->widget_fields(); $widget_fields = $this->widget_fields();
// Loop through fields // Loop through fields
foreach ( $widget_fields as $widget_field ) { foreach ( $widget_fields as $widget_field ) {
extract( $widget_field ); extract( $widget_field );
// Use helper function to get updated field values // Use helper function to get updated field values
$instance[$sophia_after_dark_widgets_name] = sophia_after_dark_widgets_updated_field_value( $widget_field, $new_instance[$sophia_after_dark_widgets_name] ); $instance[ $sophia_after_dark_widgets_name ] = sophia_after_dark_widgets_updated_field_value( $widget_field, $new_instance[ $sophia_after_dark_widgets_name ] );
} }
return $instance; return $instance;
} }
/** /**
* Back-end widget form. * Back-end widget form.
* *
* @see WP_Widget::form() * @see WP_Widget::form()
* *
* @param array $instance Previously saved values from database. * @param array $instance Previously saved values from database.
* *
* @uses sophia_after_dark_widgets_show_widget_field() defined in sad-widget-fields.php * @uses sophia_after_dark_widgets_show_widget_field() defined in sad-widget-fields.php
*/ */
public function form( $instance ) { public function form( $instance ) {
$widget_fields = $this->widget_fields(); $widget_fields = $this->widget_fields();
// Loop through fields // Loop through fields
foreach ( $widget_fields as $widget_field ) { foreach ( $widget_fields as $widget_field ) {
// Make array elements available as variables // Make array elements available as variables
extract( $widget_field ); extract( $widget_field );
$sophia_after_dark_widgets_field_value = !empty( $instance[$sophia_after_dark_widgets_name] ) ? wp_kses_post( $instance[$sophia_after_dark_widgets_name] ) : ''; $sophia_after_dark_widgets_field_value = ! empty( $instance[ $sophia_after_dark_widgets_name ] ) ? wp_kses_post( $instance[ $sophia_after_dark_widgets_name ] ) : '';
sophia_after_dark_widgets_show_widget_field( $this, $widget_field, $sophia_after_dark_widgets_field_value ); sophia_after_dark_widgets_show_widget_field( $this, $widget_field, $sophia_after_dark_widgets_field_value );
} }
} }
} }

View File

@@ -5,150 +5,151 @@
* @package Sophia After Dark * @package Sophia After Dark
* @since 1.0.0 * @since 1.0.0
*/ */
function sophia_after_dark_widgets_show_widget_field( $instance = '', $widget_field = '', $sophia_after_dark_widget_field_value = '' ) { function sophia_after_dark_widgets_show_widget_field( $instance = '', $widget_field = '', $sophia_after_dark_widget_field_value = '' ) {
extract( $widget_field ); extract( $widget_field );
switch ( $sophia_after_dark_widgets_field_type ) { switch ( $sophia_after_dark_widgets_field_type ) {
/** /**
* text widget field * text widget field
*/ */
case 'text' case 'text'
?> ?>
<p> <p>
<span class="field-label"><label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?></label></span> <span class="field-label"><label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?></label></span>
<input class="widefat" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" type="text" value="<?php echo esc_html( $sophia_after_dark_widget_field_value ); ?>" /> <input class="widefat" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" type="text" value="<?php echo esc_html( $sophia_after_dark_widget_field_value ); ?>" />
<?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?> <?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?>
<br /> <br />
<em><?php echo wp_kses_post( $sophia_after_dark_widgets_description ); ?></em> <em><?php echo wp_kses_post( $sophia_after_dark_widgets_description ); ?></em>
<?php } ?> <?php } ?>
</p> </p>
<?php <?php
break; break;
/** /**
* Select field * Select field
*/ */
case 'select' : case 'select':
if ( empty( $sophia_after_dark_widget_field_value ) ) { if ( empty( $sophia_after_dark_widget_field_value ) ) {
$sophia_after_dark_widget_field_value = $sophia_after_dark_widgets_default; $sophia_after_dark_widget_field_value = $sophia_after_dark_widgets_default;
} }
?> ?>
<p> <p>
<label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?>:</label> <label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?>:</label>
<select name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" class="widefat"> <select name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" class="widefat">
<?php foreach ( $sophia_after_dark_widgets_field_options as $select_option_name => $select_option_title ) { ?> <?php foreach ( $sophia_after_dark_widgets_field_options as $select_option_name => $select_option_title ) { ?>
<option value="<?php echo esc_attr( $select_option_name ); ?>" id="<?php echo esc_attr( $instance->get_field_id( $select_option_name ) ); ?>" <?php selected( $select_option_name, $sophia_after_dark_widget_field_value ); ?>><?php echo esc_html( $select_option_title ); ?></option> <option value="<?php echo esc_attr( $select_option_name ); ?>" id="<?php echo esc_attr( $instance->get_field_id( $select_option_name ) ); ?>" <?php selected( $select_option_name, $sophia_after_dark_widget_field_value ); ?>><?php echo esc_html( $select_option_title ); ?></option>
<?php } ?> <?php } ?>
</select> </select>
<?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?> <?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?>
<br /> <br />
<small><?php echo esc_html( $sophia_after_dark_widgets_description ); ?></small> <small><?php echo esc_html( $sophia_after_dark_widgets_description ); ?></small>
<?php } ?> <?php } ?>
</p> </p>
<?php <?php
break; break;
/** /**
* user dropdown widget field * user dropdown widget field
*/ */
case 'user_dropdown' : case 'user_dropdown':
if ( empty( $sophia_after_dark_widget_field_value ) ) { if ( empty( $sophia_after_dark_widget_field_value ) ) {
$sophia_after_dark_widget_field_value = $sophia_after_dark_widgets_default; $sophia_after_dark_widget_field_value = $sophia_after_dark_widgets_default;
} }
$select_field = 'name="'. esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ) .'" id="'. esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ) .'" class="widefat"'; $select_field = 'name="' . esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ) . '" id="' . esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ) . '" class="widefat"';
?> ?>
<p> <p>
<label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?>:</label> <label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?>:</label>
<?php <?php
$dropdown_args = wp_parse_args( array( $dropdown_args = wp_parse_args(
'show_option_none' => __( '- - Select User - -', 'sophia-after-dark' ), array(
'selected' => esc_attr( $sophia_after_dark_widget_field_value ), 'show_option_none' => __( '- - Select User - -', 'sophia-after-dark' ),
) ); 'selected' => esc_attr( $sophia_after_dark_widget_field_value ),
)
);
$dropdown_args['echo'] = false; $dropdown_args['echo'] = false;
$dropdown = wp_dropdown_users( $dropdown_args ); $dropdown = wp_dropdown_users( $dropdown_args );
$dropdown = str_replace( '<select', '<select ' . $select_field, $dropdown ); $dropdown = str_replace( '<select', '<select ' . $select_field, $dropdown );
echo $dropdown; echo $dropdown;
?> ?>
</p> </p>
<?php <?php
break; break;
/** /**
* number widget field * number widget field
*/ */
case 'number' : case 'number':
if ( empty( $sophia_after_dark_widget_field_value ) ) { if ( empty( $sophia_after_dark_widget_field_value ) ) {
$sophia_after_dark_widget_field_value = $sophia_after_dark_widgets_default; $sophia_after_dark_widget_field_value = $sophia_after_dark_widgets_default;
} }
?> ?>
<p> <p>
<label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?></label> <label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?></label>
<input name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" type="number" step="1" min="1" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" value="<?php echo esc_html( $sophia_after_dark_widget_field_value ); ?>" class="small-text" /> <input name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" type="number" step="1" min="1" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" value="<?php echo esc_html( $sophia_after_dark_widget_field_value ); ?>" class="small-text" />
<?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?> <?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?>
<br /> <br />
<em><?php echo wp_kses_post( $sophia_after_dark_widgets_description ); ?></em> <em><?php echo wp_kses_post( $sophia_after_dark_widgets_description ); ?></em>
<?php } ?> <?php } ?>
</p> </p>
<?php <?php
break; break;
/** /**
* upload file field * upload file field
*/ */
case 'upload': case 'upload':
$image = $image_class = ""; $image = $image_class = '';
if ( $sophia_after_dark_widget_field_value ) { if ( $sophia_after_dark_widget_field_value ) {
$image = '<img src="'.esc_url( $sophia_after_dark_widget_field_value ).'" style="max-width:100%;"/>'; $image = '<img src="' . esc_url( $sophia_after_dark_widget_field_value ) . '" style="max-width:100%;"/>';
$image_class = ' hidden'; $image_class = ' hidden';
} }
?> ?>
<div class="attachment-media-view"> <div class="attachment-media-view">
<label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?>:</label><br /> <label for="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>"><?php echo esc_html( $sophia_after_dark_widgets_title ); ?>:</label><br />
<div class="placeholder<?php echo esc_attr( $image_class ); ?>"> <div class="placeholder<?php echo esc_attr( $image_class ); ?>">
<?php esc_html_e( 'No image selected', 'sophia-after-dark' ); ?> <?php esc_html_e( 'No image selected', 'sophia-after-dark' ); ?>
</div> </div>
<div class="thumbnail thumbnail-image"> <div class="thumbnail thumbnail-image">
<?php echo $image; ?> <?php echo $image; ?>
</div> </div>
<div class="actions sad-clearfix"> <div class="actions sad-clearfix">
<button type="button" class="button sad-delete-button align-left"><?php esc_html_e( 'Remove', 'sophia-after-dark' ); ?></button> <button type="button" class="button sad-delete-button align-left"><?php esc_html_e( 'Remove', 'sophia-after-dark' ); ?></button>
<button type="button" class="button sad-upload-button alignright"><?php esc_html_e( 'Select Image', 'sophia-after-dark' ); ?></button> <button type="button" class="button sad-upload-button alignright"><?php esc_html_e( 'Select Image', 'sophia-after-dark' ); ?></button>
<input name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" class="upload-id" type="hidden" value="<?php echo esc_url( $sophia_after_dark_widget_field_value ) ?>"/> <input name="<?php echo esc_attr( $instance->get_field_name( $sophia_after_dark_widgets_name ) ); ?>" id="<?php echo esc_attr( $instance->get_field_id( $sophia_after_dark_widgets_name ) ); ?>" class="upload-id" type="hidden" value="<?php echo esc_url( $sophia_after_dark_widget_field_value ); ?>"/>
</div> </div>
<?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?> <?php if ( isset( $sophia_after_dark_widgets_description ) ) { ?>
<br /> <br />
<small><?php echo wp_kses_post( $sophia_after_dark_widgets_description ); ?></small> <small><?php echo wp_kses_post( $sophia_after_dark_widgets_description ); ?></small>
<?php } ?> <?php } ?>
</div> </div>
<?php <?php
break; break;
} }
} }
function sophia_after_dark_widgets_updated_field_value( $widget_field, $new_field_value ) { function sophia_after_dark_widgets_updated_field_value( $widget_field, $new_field_value ) {
extract( $widget_field ); extract( $widget_field );
if ( $sophia_after_dark_widgets_field_type == 'number') { if ( $sophia_after_dark_widgets_field_type == 'number' ) {
return absint( $new_field_value ); return absint( $new_field_value );
} elseif ( $sophia_after_dark_widgets_field_type == 'upload' ) { } elseif ( $sophia_after_dark_widgets_field_type == 'upload' ) {
return esc_url( $new_field_value ); return esc_url( $new_field_value );
} else { } else {
return sanitize_text_field( $new_field_value ); return sanitize_text_field( $new_field_value );
} }
} }

View File

@@ -17,32 +17,36 @@ function sophia_after_dark_widgets_init() {
* *
* @since 1.0.0 * @since 1.0.0
*/ */
register_sidebar( array( register_sidebar(
'name' => esc_html__( 'Sidebar', 'sophia-after-dark' ), array(
'id' => 'sidebar-1', 'name' => esc_html__( 'Sidebar', 'sophia-after-dark' ),
'description' => esc_html__( 'Add widgets here.', 'sophia-after-dark' ), 'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'sophia-after-dark' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">', 'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>', 'after_widget' => '</section>',
'before_title' => '<h4 class="widget-title">', 'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>', 'after_title' => '</h4>',
) ); )
);
/** /**
* Register Header Ads Section * Register Header Ads Section
* *
* @since 1.0.0 * @since 1.0.0
*/ */
register_sidebar( array( register_sidebar(
'name' => esc_html__( 'Header Ads Section', 'sophia-after-dark' ), array(
'id' => 'header-ads-section', 'name' => esc_html__( 'Header Ads Section', 'sophia-after-dark' ),
'description' => esc_html__( 'Add MT: Ads Banner widgets here.', 'sophia-after-dark' ), 'id' => 'header-ads-section',
'description' => esc_html__( 'Add MT: Ads Banner widgets here.', 'sophia-after-dark' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">', 'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>', 'after_widget' => '</section>',
'before_title' => '<h4 class="widget-title">', 'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>', 'after_title' => '</h4>',
) ); )
);
/** /**
* Register 4 different footer area * Register 4 different footer area
@@ -50,15 +54,18 @@ function sophia_after_dark_widgets_init() {
* @since 1.0.0 * @since 1.0.0
*/ */
register_sidebars( 4 , array( register_sidebars(
'name' => esc_html__( 'Footer %d', 'sophia-after-dark' ), 4,
'id' => 'footer-sidebar', array(
'description' => esc_html__( 'Added widgets are display at Footer Widget Area.', 'sophia-after-dark' ), 'name' => esc_html__( 'Footer %d', 'sophia-after-dark' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">', 'id' => 'footer-sidebar',
'after_widget' => '</section>', 'description' => esc_html__( 'Added widgets are display at Footer Widget Area.', 'sophia-after-dark' ),
'before_title' => '<h4 class="widget-title">', 'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_title' => '</h4>', 'after_widget' => '</section>',
) ); 'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
// Author Info // Author Info
register_widget( 'sophia_after_dark_Author_Info' ); register_widget( 'sophia_after_dark_Author_Info' );
@@ -66,7 +73,7 @@ function sophia_after_dark_widgets_init() {
// Latest Posts // Latest Posts
register_widget( 'sophia_after_dark_Latest_Posts' ); register_widget( 'sophia_after_dark_Latest_Posts' );
//Social Media // Social Media
register_widget( 'sophia_after_dark_Social_Media' ); register_widget( 'sophia_after_dark_Social_Media' );
} }
add_action( 'widgets_init', 'sophia_after_dark_widgets_init' ); add_action( 'widgets_init', 'sophia_after_dark_widgets_init' );

View File

@@ -17,7 +17,7 @@ declare(strict_types=1);
get_header(); get_header();
$archive_style = get_theme_mod('sophia_after_dark_archive_style', 'sad-archive--masonry-style'); $archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' );
?> ?>
@@ -25,36 +25,36 @@ $archive_style = get_theme_mod('sophia_after_dark_archive_style', 'sad-archive--
<div itemscope id="primary" class="content-area"> <div itemscope id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php if ('sad-archive--block-grid-style' === $archive_style): ?> <?php if ( 'sad-archive--block-grid-style' === $archive_style ) : ?>
<div class="archive-grid-post-wrapper"> <div class="archive-grid-post-wrapper">
<?php endif; ?> <?php endif; ?>
<?php if (have_posts()): ?> <?php if ( have_posts() ) : ?>
<?php if ('sad-archive--masonry-style' === $archive_style): ?> <?php if ( 'sad-archive--masonry-style' === $archive_style ) : ?>
<div class="sophia-after-dark-content-masonry"> <div class="sophia-after-dark-content-masonry">
<div id="sad-masonry"> <div id="sad-masonry">
<?php endif; ?> <?php endif; ?>
<?php <?php
while (have_posts()): while ( have_posts() ) :
the_post(); the_post();
get_template_part('template-parts/content', get_post_format()); get_template_part( 'template-parts/content', get_post_format() );
endwhile; endwhile;
?> ?>
<?php if ('sad-archive--masonry-style' === $archive_style): ?> <?php if ( 'sad-archive--masonry-style' === $archive_style ) : ?>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php the_posts_pagination(); ?> <?php the_posts_pagination(); ?>
<?php else: ?> <?php else : ?>
<?php get_template_part('template-parts/content', 'none'); ?> <?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?> <?php endif; ?>
<?php if ('sad-archive--block-grid-style' === $archive_style): ?> <?php if ( 'sad-archive--block-grid-style' === $archive_style ) : ?>
</div> </div>
<?php endif; ?> <?php endif; ?>

16
phpcs.xml Normal file
View File

@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<ruleset name="WordPress Theme Standards">
<description>WordPress Coding Standards</description>
<rule ref="WordPress-Core" />
<rule ref="WordPress-Docs" />
<rule ref="WordPress-Extra" />
<arg name="extensions" value="php"/>
<file>.</file>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/assets/*</exclude-pattern>
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*.min.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
</ruleset>

View File

@@ -21,10 +21,10 @@ get_header();
if ( have_posts() ) : if ( have_posts() ) :
if ( 'sad-archive--masonry-style' === $archive_style ) : if ( 'sad-archive--masonry-style' === $archive_style ) :
?> ?>
<div class="sophia-after-dark-content-masonry"> <div class="sophia-after-dark-content-masonry">
<div id="sad-masonry"> <div id="sad-masonry">
<?php <?php
endif; endif;
/* Start the Loop */ /* Start the Loop */
@@ -34,10 +34,10 @@ get_header();
endwhile; endwhile;
if ( 'sad-archive--masonry-style' === $archive_style ) : if ( 'sad-archive--masonry-style' === $archive_style ) :
?> ?>
</div> </div>
</div> </div>
<?php <?php
endif; endif;
the_posts_pagination(); the_posts_pagination();

View File

@@ -24,39 +24,39 @@ $layout = get_theme_mod( 'sophia_after_dark_widget_area_layout', 'column-three'
?> ?>
<div id="top-footer" class="footer-widgets-wrapper footer-<?php echo esc_attr( $layout ); ?> sad-clearfix"> <div id="top-footer" class="footer-widgets-wrapper footer-<?php echo esc_attr( $layout ); ?> sad-clearfix">
<div class="sad-container"> <div class="sad-container">
<div class="footer-widgets-area sad-clearfix"> <div class="footer-widgets-area sad-clearfix">
<div class="sad-footer-widget-wrapper sad-column-wrapper sad-clearfix"> <div class="sad-footer-widget-wrapper sad-column-wrapper sad-clearfix">
<?php <?php
// Footer widget 1 (always shown) // Footer widget 1 (always shown)
echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="0.3s">'; echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="0.3s">';
dynamic_sidebar( 'footer-sidebar' ); dynamic_sidebar( 'footer-sidebar' );
echo '</div>'; echo '</div>';
// Footer widget 2 (shown in all but column-one layout) // Footer widget 2 (shown in all but column-one layout)
if ( $layout !== 'column-one' ) { if ( $layout !== 'column-one' ) {
echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="0.6s">'; echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="0.6s">';
dynamic_sidebar( 'footer-sidebar-2' ); dynamic_sidebar( 'footer-sidebar-2' );
echo '</div>'; echo '</div>';
} }
// Footer widget 3 (only for three or four column layouts) // Footer widget 3 (only for three or four column layouts)
if ( in_array( $layout, [ 'column-three', 'column-four' ], true ) ) { if ( in_array( $layout, array( 'column-three', 'column-four' ), true ) ) {
echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="0.9s">'; echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="0.9s">';
dynamic_sidebar( 'footer-sidebar-3' ); dynamic_sidebar( 'footer-sidebar-3' );
echo '</div>'; echo '</div>';
} }
// Footer widget 4 (only for four column layout) // Footer widget 4 (only for four column layout)
if ( $layout === 'column-four' ) { if ( $layout === 'column-four' ) {
echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="1.2s">'; echo '<div class="sad-footer-widget wow fadeInLeft" data-wow-duration="1.2s">';
dynamic_sidebar( 'footer-sidebar-4' ); dynamic_sidebar( 'footer-sidebar-4' );
echo '</div>'; echo '</div>';
} }
?> ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -6,11 +6,11 @@
* @since 1.0.0 * @since 1.0.0
*/ */
$author_id = get_the_author_meta( 'ID' ); $author_id = get_the_author_meta( 'ID' );
$author_avatar = get_avatar( $author_id, 'thumbnail' ); $author_avatar = get_avatar( $author_id, 'thumbnail' );
$author_post_link = get_the_author_posts_link(); $author_post_link = get_the_author_posts_link();
$author_bio = get_the_author_meta( 'description' ); $author_bio = get_the_author_meta( 'description' );
$author_url = get_the_author_meta( 'user_url' ); $author_url = get_the_author_meta( 'user_url' );
?> ?>
<div class="sad-author-box"> <div class="sad-author-box">

View File

@@ -12,11 +12,13 @@
<div class="entry-content"> <div class="entry-content">
<?php <?php
the_content(); the_content();
wp_link_pages( array( wp_link_pages(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'sophia-after-dark' ), array(
'after' => '</div>', 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'sophia-after-dark' ),
) ); 'after' => '</div>',
?> )
);
?>
</div> </div>
<?php if ( get_edit_post_link() ) : ?> <?php if ( get_edit_post_link() ) : ?>

View File

@@ -8,7 +8,7 @@
* @since 1.0.0 * @since 1.0.0
*/ */
$post_content_type = apply_filters( 'sophia_after_dark_archive_post_content_type', 'excerpt' ); $post_content_type = apply_filters( 'sophia_after_dark_archive_post_content_type', 'excerpt' );
$post_class = has_post_thumbnail() ? 'has-thumbnail wow fadeInUp' : 'no-thumbnail wow fadeInUp'; $post_class = has_post_thumbnail() ? 'has-thumbnail wow fadeInUp' : 'no-thumbnail wow fadeInUp';
?> ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>>
@@ -30,13 +30,15 @@ $post_class = has_post_thumbnail() ? 'has-thumbnail wow fadeInUp' : 'no-thumbnai
<?php endif; ?> <?php endif; ?>
<header class="entry-header"> <header class="entry-header">
<?php the_title( <?php
the_title(
sprintf( sprintf(
'<h2 class="entry-title"><a href="%s" rel="bookmark">', '<h2 class="entry-title"><a href="%s" rel="bookmark">',
esc_url( get_permalink() ) esc_url( get_permalink() )
), ),
'</a></h2>' '</a></h2>'
); ?> );
?>
</header> </header>
<div class="entry-content"> <div class="entry-content">
@@ -44,13 +46,15 @@ $post_class = has_post_thumbnail() ? 'has-thumbnail wow fadeInUp' : 'no-thumbnai
<?php the_excerpt(); ?> <?php the_excerpt(); ?>
<?php elseif ( 'content' === $post_content_type ) : ?> <?php elseif ( 'content' === $post_content_type ) : ?>
<?php <?php
the_content( sprintf( the_content(
wp_kses( sprintf(
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'sophia-after-dark' ), wp_kses(
[ 'span' => [ 'class' => [] ] ] __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'sophia-after-dark' ),
), array( 'span' => array( 'class' => array() ) )
get_the_title() ),
) ); get_the_title()
)
);
?> ?>
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@@ -13,43 +13,47 @@ $post_class = has_post_thumbnail() ? 'has-thumbnail' : 'no-thumbnail';
<article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>>
<?php if ( has_post_thumbnail() ) : ?> <?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbnail"> <div class="post-thumbnail">
<?php the_post_thumbnail( 'full' ); ?> <?php the_post_thumbnail( 'full' ); ?>
<div class="post-info-wrap"> <div class="post-info-wrap">
<div class="post-cat"><?php sophia_after_dark_article_categories_list(); ?></div> <div class="post-cat"><?php sophia_after_dark_article_categories_list(); ?></div>
<div class="entry-meta"> <div class="entry-meta">
<?php <?php
sophia_after_dark_posted_on(); sophia_after_dark_posted_on();
sophia_after_dark_posted_by(); sophia_after_dark_posted_by();
?> ?>
</div> </div>
<?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?> <?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<div class="entry-content"> <div class="entry-content">
<?php <?php
the_content( sprintf( the_content(
wp_kses( sprintf(
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'sophia-after-dark' ), wp_kses(
[ 'span' => [ 'class' => [] ] ] __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'sophia-after-dark' ),
), array( 'span' => array( 'class' => array() ) )
get_the_title() ),
) ); get_the_title()
)
);
wp_link_pages( [ wp_link_pages(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'sophia-after-dark' ), array(
'after' => '</div>', 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'sophia-after-dark' ),
] ); 'after' => '</div>',
?> )
</div> );
?>
</div>
<footer class="entry-footer"> <footer class="entry-footer">
<?php sophia_after_dark_entry_footer(); ?> <?php sophia_after_dark_entry_footer(); ?>
</footer> </footer>
<?php get_template_part( 'template-parts/author/post', 'author-box' ); ?> <?php get_template_part( 'template-parts/author/post', 'author-box' ); ?>
</article> </article>

View File

@@ -9,55 +9,57 @@
*/ */
global $wp_query; global $wp_query;
$current_post = $wp_query->current_post; $current_post = $wp_query->current_post;
$archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' ); $archive_style = get_theme_mod( 'sophia_after_dark_archive_style', 'sad-archive--masonry-style' );
$post_content_type = apply_filters( 'sophia_after_dark_archive_post_content_type', 'excerpt' ); $post_content_type = apply_filters( 'sophia_after_dark_archive_post_content_type', 'excerpt' );
// Determine post class // Determine post class
$post_class = has_post_thumbnail() ? 'has-thumbnail' : 'no-thumbnail'; $post_class = has_post_thumbnail() ? 'has-thumbnail' : 'no-thumbnail';
if ( $current_post >= 3 || 'sad-archive--masonry-style' !== $archive_style ) { if ( $current_post >= 3 || 'sad-archive--masonry-style' !== $archive_style ) {
$post_class .= ' wow fadeInUp'; $post_class .= ' wow fadeInUp';
} }
?> ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>>
<div class="thumb-cat-wrap"> <div class="thumb-cat-wrap">
<?php <?php
sophia_after_dark_post_thumbnail(); sophia_after_dark_post_thumbnail();
sophia_after_dark_article_categories_list(); sophia_after_dark_article_categories_list();
?> ?>
</div> </div>
<?php if ( 'post' === get_post_type() ) : ?> <?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-cat"> <div class="entry-cat">
<?php <?php
sophia_after_dark_posted_on(); sophia_after_dark_posted_on();
sophia_after_dark_posted_by(); sophia_after_dark_posted_by();
?> ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<header class="entry-header"> <header class="entry-header">
<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?> <?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
</header> </header>
<div class="entry-content"> <div class="entry-content">
<?php <?php
if ( 'excerpt' === $post_content_type ) { if ( 'excerpt' === $post_content_type ) {
the_excerpt(); the_excerpt();
} elseif ( 'content' === $post_content_type ) { } elseif ( 'content' === $post_content_type ) {
the_content( sprintf( the_content(
wp_kses( sprintf(
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'sophia-after-dark' ), wp_kses(
[ 'span' => [ 'class' => [] ] ] __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'sophia-after-dark' ),
), array( 'span' => array( 'class' => array() ) )
get_the_title() ),
) ); get_the_title()
} )
?> );
</div> }
?>
</div>
<footer class="entry-footer"> <footer class="entry-footer">
<?php sophia_after_dark_entry_footer(); ?> <?php sophia_after_dark_entry_footer(); ?>
</footer> </footer>
</article> </article>

View File

@@ -6,34 +6,34 @@
* @since 1.0.0 * @since 1.0.0
*/ */
$post_class = has_post_thumbnail() ? "has-thumbnail wow fadeInUp" : "no-thumbnail wow fadeInUp"; $post_class = has_post_thumbnail() ? 'has-thumbnail wow fadeInUp' : 'no-thumbnail wow fadeInUp';
?> ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class( $post_class ); ?>>
<div class="thumb-cat-wrap"> <div class="thumb-cat-wrap">
<?php if ( has_post_thumbnail() ) : ?> <?php if ( has_post_thumbnail() ) : ?>
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark"> <a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php sophia_after_dark_post_thumbnail(); ?> <?php sophia_after_dark_post_thumbnail(); ?>
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php sophia_after_dark_article_categories_list(); ?> <?php sophia_after_dark_article_categories_list(); ?>
</div> </div>
<?php if ( "post" === get_post_type() ) : ?> <?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-cat"> <div class="entry-cat">
<?php <?php
sophia_after_dark_posted_on(); sophia_after_dark_posted_on();
sophia_after_dark_posted_by(); sophia_after_dark_posted_by();
?> ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<header class="entry-header"> <header class="entry-header">
<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?> <?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
</header> </header>
<footer class="entry-footer"> <footer class="entry-footer">
<?php sophia_after_dark_entry_footer(); ?> <?php sophia_after_dark_entry_footer(); ?>
</footer> </footer>
</article> </article>

View File

@@ -8,34 +8,34 @@
global $post; global $post;
$related_post_id = get_the_ID(); $related_post_id = get_the_ID();
$get_categories = get_the_terms( $related_post_id, 'category' ); $get_categories = get_the_terms( $related_post_id, 'category' );
$selected_cat = ! empty( $get_categories ) && is_array( $get_categories ) ? wp_list_pluck( $get_categories, 'term_id' ) : []; $selected_cat = ! empty( $get_categories ) && is_array( $get_categories ) ? wp_list_pluck( $get_categories, 'term_id' ) : array();
$related_posts_count = apply_filters( 'sophia_after_dark_related_posts_count', 3 ); $related_posts_count = apply_filters( 'sophia_after_dark_related_posts_count', 3 );
$related_posts_title = apply_filters( 'sophia_after_dark_related_posts_section_title', __( 'Related Posts', 'sophia-after-dark' ) ); $related_posts_title = apply_filters( 'sophia_after_dark_related_posts_section_title', __( 'Related Posts', 'sophia-after-dark' ) );
$related_posts_args = [ $related_posts_args = array(
'posts_per_page' => absint( $related_posts_count ), 'posts_per_page' => absint( $related_posts_count ),
'post__not_in' => [ $related_post_id ], 'post__not_in' => array( $related_post_id ),
'category__in' => $selected_cat, 'category__in' => $selected_cat,
]; );
$related_posts_query = new WP_Query( $related_posts_args ); $related_posts_query = new WP_Query( $related_posts_args );
if ( $related_posts_query->have_posts() ) : if ( $related_posts_query->have_posts() ) :
?> ?>
<section class="sad-single-related-posts"> <section class="sad-single-related-posts">
<h2 class="sad-related-post-title"><?php echo esc_html( $related_posts_title ); ?></h2> <h2 class="sad-related-post-title"><?php echo esc_html( $related_posts_title ); ?></h2>
<div class="sad-related-posts-wrapper"> <div class="sad-related-posts-wrapper">
<?php <?php
while ( $related_posts_query->have_posts() ) : while ( $related_posts_query->have_posts() ) :
$related_posts_query->the_post(); $related_posts_query->the_post();
get_template_part( 'template-parts/related/content', 'related' ); get_template_part( 'template-parts/related/content', 'related' );
endwhile; endwhile;
?> ?>
</div> </div>
</section> </section>
<?php <?php
endif; endif;
wp_reset_postdata(); wp_reset_postdata();