',
) );
register_sidebar( array(
'name' => __( 'PreContent Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'precontent-widget',
'description' => __( 'Widgets in this area will be shown in the main content, above the posts and
sidebar. Ideal for a slideshow. Is full width with no left and right spacing.',
BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'PreContent Widget About Me', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'precontent-widget-about-me',
'description' => __( 'Widgets in this area will be shown on the about me page in the main content,
above the posts and sidebar. It is ideal for a slideshow. Is full width with no
left and right spacing.', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Preposts Left Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'preposts-widget-left',
'description' => __( 'Widgets in this area will be shown in the main content area of the blog
landing page on the left,above the main posts. It is recommended that if you
place widgets in this area, do so in the preposts right widget area also. If no
widgets are dragged into the area, will not show anything.', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'PrePosts Right Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'preposts-widget-right',
'description' => __( 'Widgets in this area will be shown in the main content area of the blog
landing page on the right,above the main posts. It is recommended that if you
place widgets in this area, do so in the preposts left widget area also. If no
widgets are dragged into the area, will not show anything.', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Main Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'main-widget',
'description' => __( 'This area is where the main wordpress loop is shown. You can override this
behavior by dragging widgets to this area.', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Post Posts Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'post-posts-widget',
'description' => __( 'Widgets in this area will be shown in the main content, below the posts and
sidebar. It is ideal for advertisement or a call to action box. Is full width,
with no side paddings.', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Sidebar Right', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'sidebar-rght',
'description' => __( 'Widgets in this area will be shown in the right sidebar', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Single Post After Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'single-post-after-widget',
'description' => __( 'Widgets in this area will be shown in the on single post pages, immediately below the author bio. It is ideal for related posts. ', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Left Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'footer-widget-lft',
'description' => __( 'Widgets in this area will be shown in the left footer column', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Middle Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'footer-widget-mid',
'description' => __( 'Widgets in this area will be shown in the center footer column', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Right Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'footer-widget-rght',
'description' => __( 'Widgets in this area will be shown in the right footer column', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Bottom Left Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'footer-widget-btm-lft',
'description' => __( 'Widgets in this area will be shown in the bottom left footer column',
BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Bottom Right Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'footer-widget-btm-rght',
'description' => __( 'Widgets in this area will be shown in the bottom right footer column',
BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
' . __( 'First we would like to say Thank You for downloading the BlogCentral Theme. The following provides some information about using the theme\'s options page. For more detailed
information, consult the readme.txt file and the theme\'s online documentation at Documentation on ' . BLOGCENTRAL_THEME_NAME . '.', BLOGCENTRAL_TXT_DOMAIN ) .
'
' . __( 'BlogCentral uses the native Wordpress color picker to choose a color. You can also enter the color manually. Examples: #ffffff, rgb(255,255,255) or white.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'When choosing a background image, there are many options available. As with all images, it is strongly recommended to enter a value for the alternate text option.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'Enter font sizes, padding, margins, widths, and heights with unit of measurement, eg. 12px, 1.2rem etc. For dimensions of an image, do not include a unit of measurement.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
/**
* Construct help panel for the contact tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_contact_help_tab() {
$html = '
' . __( 'This theme is compatible with any plugin that displays contact forms via a shortcode. If you would like to display a contact form, enter the shortcode generated by the plugin in the textarea.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
/**
* Construct help panel for the typography tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_typography_help_tab() {
$html = '
' . __( 'You can customize the font family, weight and style, and subsets for the body text, headers, and menu items. Choose from traditional system fonts and google fonts.', BLOGCENTRAL_TXT_DOMAIN ) .
'
';
return $html;
}
/**
* Construct help panel for the social api tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_social_api_help_tab() {
$html = '
' . __( 'Third Party APIs', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'If you would like to use the facebook comments, and google maps and fonts, you must provide your API keys for each platform. Visit their website to obtain this information.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
/**
* Construct help panel for the header tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_header_help_tab() {
$html = '
' . __( 'Contact Information Display', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'BlogCentral provides options to display the contact information for a company or an individual. If the option for a user id is blank, then the contact information entered in the contact tab on the theme\'s options page will be used, otherwise the contact information for the user of the provided user id will be displayed. For social media contacts, enter the full url, ie. http://www.facebook.com/username.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
/**
* Construct help panel for the posts tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_posts_help_tab() {
$html = '
' . __( 'Options on this page determine how posts listing is displayed on the front, archive, author, search, category and tags pages.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'Single Post Page', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'BlogCentral offers the option to use the same settings of the landing page for the single post page. If you choose to override the settings, then none of them will be used for the single post page.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
/**
* 5.3 Controller + Save Theme Settings
*-----------------------------------------------------------------------*/
/**
* Route url requests to the appropriate function.
*
* @since 1.0.0
*/
function blogcentral_front_controller() {
$action = isset( $_GET['action'] ) ? $_GET['action'] : ( isset( $_POST['action'] ) ? $_POST['action'] : '' );
if ( isset( $_GET['page'] ) && 'blogcentral_options' === $_GET['page'] ) {
switch ( $action ) {
case 'blogcentral_options':
default:
blogcentral_theme_options();
}
}// End if
}
/**
* Perform security checks on theme options
*
* Construct the google fonts url for any google font option selected.
*
* @since 1.0.0
*/
function blogcentral_validate_options() {
global $blogcentral_opts;
global $blogcentral_defaults;
$check_text = array( "body_bck_img_alt", "default_user_img_alt", 'contact_address', "contact_phone",
"address_icon", "phone_icon", "url_icon", "email_icon", "facebook_icon", "twitter_icon", "google_icon",
"linkedin_icon", "instagram_icon", "tumblr_icon", "pinterest_icon", "facebook_app_id", "google_app_id",
"logo_alt", "img_size", "standard_icon", "image_icon", "audio_icon", "video_icon", "gallery_icon",
"link_icon", "quote_icon", "author_icon", "date_icon", "categories_icon", "tags_icon", "comments_icon",
);
$check_int = array( "color_scheme", "body_bck_img_width", "body_bck_img_height", "page_header_bck_img_width",
"page_header_bck_img_height", "default_user_img_width", "default_user_img_height", "user_id",
);
$check_url = array( 'contact_url', 'contact_facebook', 'contact_twitter', 'contact_google',
'contact_linkedin', 'contact_instagram', 'contact_tumblr', 'contact_pinterest',
);
$check_email = array( 'contact_email', );
$check_html = array( 'copyright', );
$check_html_limited = array( 'title_text', 'tagline_text', "share_title", );
$check_html_class = array( "wrap_class", "title_class", );
// Only allow these tags with these attributes.
$kses_allow = array(
'a' => array(
'href' => array(),
'title' => array(),
),
'br' => array(),
'span' => array(
'id' => array(),
'class' => array(),
),
);
// Do server-side validations
$excpts = false;
$options = array();
if ( ! is_array( $_POST ) ) {
// Error do not save.
add_settings_error(
'Post-not-array',
esc_attr( 'not-array' ),
__( 'Error: The post variable is corrupted. Please contact the administrator.', BLOGCENTRAL_TXT_DOMAIN ),
'error'
);
$excpts = true;
} else {
foreach ( $_POST['blogcentral'] as $post => $vpost ) {
// First check if it is a valid theme option.
if ( ! array_key_exists( $post, $blogcentral_defaults ) ) {
continue;
}
if ( is_array( $vpost ) ) {
$flag = false;
$temp = array();
foreach ( $vpost as $key => $val ) {
if ( '' !== $val ) {
// Do security checks
if ( in_array( $val, $check_text ) ) {
$val = sanitize_text_field( $val );
} elseif ( in_array( $val, $check_url ) ) {
$val = esc_url_raw( $val );
} elseif ( in_array( $val, $check_email ) ) {
$val = sanitize_email( $val );
} elseif ( in_array( $val, $check_int ) ) {
$val = absint( $val );
} elseif ( in_array( $val, $check_html ) ) {
$val = wp_kses_post( $val );
} elseif ( in_array( $val, $check_html_limited ) ) {
$val = wp_kses( $val, $kses_allow );
} elseif ( in_array( $val, $check_html_class ) ) {
$val = sanitize_html_class( $val );
}
$flag = true;
$temp[$key] = $val;
}
}
if ( $flag ) {
$options[$post] = array();
$options[$post] = $temp;
}
} else {
if ( '' !== $vpost ) {
// Do security checks
if ( in_array( $vpost, $check_text ) ) {
$vpost = sanitize_text_field( $vpost );
} elseif ( in_array( $vpost, $check_url ) ) {
$vpost = esc_url_raw( $vpost );
} elseif ( in_array( $vpost, $check_email ) ) {
$vpost = sanitize_email( $vpost );
} elseif ( in_array( $vpost, $check_int ) ) {
$vpost = absint( $vpost );
} elseif ( in_array( $vpost, $check_html ) ) {
$vpost = wp_kses_post( $vpost );
} elseif ( in_array( $vpost, $check_html_limited ) ) {
$vpost = wp_kses( $vpost, $kses_allow );
} elseif ( in_array( $vpost, $check_html_class ) ) {
$vpost = sanitize_html_class( $vpost );
}
$options[$post] = $vpost;
}
}
}
// Construct google fonts url to save to the database.
$fonts = blogcentral_construct_google_fonts_url();
$options['google_fonts_url'] = $fonts;
// Update global variable with new options
$blogcentral_opts = $options;
}
// Output any errors or confirmation messages.
if ( ! $excpts ) {
add_settings_error(
'options-saved',
esc_attr( 'options-saved' ),
__( 'All options saved successfully!', BLOGCENTRAL_TXT_DOMAIN ),
'updated'
);
}
return $options;
}
/**
* Output any admin notices
*
* @since 1.0.0
*/
function blogcentral_admin_notices() {
settings_errors();
}
/**
* Change the blog demo and save options to database.
*
* @since 1.0.0
*
* @param string $selected Optional. Saved border.
*/
function blogcentral_change_blog_demo() {
// Check nonce.
$nonce = $_REQUEST['blogcentral_demo_nonce'];
if ( ! wp_verify_nonce( $nonce, 'blogcentral-change-demo' ) ) {
// This nonce is not valid.
die( 'No Swiping' );
} else {
global $blogcentral_opts;
global $blogcentral_blog_demos_opts;
$template = isset( $_POST['blogcentral']['blog_demo'] ) ? $_POST['blogcentral']['blog_demo'] : '';
if ( empty( $template ) && '0' !== $template ) {
// Error
$_POST['messages'] = array( __( 'Please select a blog demo', BLOGCENTRAL_TXT_DOMAIN ) );
return;
}
if ( '0' === $template ) {
$_POST['messages'] = array( __( "If you do not want to use a blog demo, and you need to save your options, click the 'Save Options' button.", BLOGCENTRAL_TXT_DOMAIN ) );
return;
}
// Save options.
update_option( BLOGCENTRAL_DB_OPTIONS_NAME, $blogcentral_blog_demos_opts[ $template - 1 ] );
// Update global variable with new options
$blogcentral_opts = $blogcentral_blog_demos_opts[ $template - 1 ];
$_POST['messages'] = array( __( 'Blog Demo Changed Successfully!', BLOGCENTRAL_TXT_DOMAIN ) );
}
}
/**
* 5.4 Theme Options
*-----------------------------------------------------------------------*/
/**
* 5.4.1 Main
*-----------------------------------------------------------------------*/
/**
* Construct name of input field for use on options, shortcode, and widget options pages.
*
* A wrapper used to name a field regularly or, if displaying options for a widget, use the widgets'
* get_field_name method.
*
* @since 1.0.0
*
* @param string $name Required. Name of input field.
* @param string $name_attr_pre Required. Name prefix of input field.
* @param object $widget Optional. Widget object to display options for.
* @return string. Modified name of input field.
*/
function blogcentral_get_field_name_wrap( $name, $name_attr_pre, & $widget = false ) {
if ( empty( $name ) || empty( $name_attr_pre ) ) {
return;
} else {
$frag = "[$name]";
}
return ( $widget ? $widget->get_field_name( $name ) : $name_attr_pre . $frag );
}
/**
* Construct id for use on options, shortcode, and widget options pages.
*
* A wrapper used to create an id. if displaying options for a widget, uses the widgets'
* get_field_id method.
*
* @since 1.0.0
*
* @param string $id Required. Id of input field.
* @param string $name_attr_pre Optional. Prefix for name attribute.
* @param object $widget Optional. Widget object if displaying options for a widget.
* @return string. Modified name of input field.
*/
function blogcentral_get_field_id_wrap( $id, $name_attr_pre, & $widget = false ) {
if ( empty( $name_attr_pre ) ) {
return;
}
return ( $widget ? $widget->get_field_id( $id ) : $name_attr_pre . '-' . $id );
}
/**
* Register theme options with the settings api
*
* @since 1.0.0
*/
function blogcentral_register_theme_options() {
register_setting( 'blogcentral', BLOGCENTRAL_DB_OPTIONS_NAME, 'blogcentral_validate_options' );
}
/**
* Display the theme options page.
*
* @since 1.0.0
*/
function blogcentral_theme_options() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.', BLOGCENTRAL_TXT_DOMAIN ) );
}
// Get the saved settings.
global $blogcentral_opts;
global $blogcentral_defaults;
global $blogcentral_initial;
// Global plugin object.
global $bcswp_plugin;
$saved = $blogcentral_opts;
if ( ! empty( $saved ) ) {
$saved = array_map( 'stripslashes_deep', $saved );
foreach ( $saved as $key => $val ) {
if ( is_array( $val ) ) {
$saved[$key] = wp_parse_args( $saved[$key], $blogcentral_defaults[$key] );
}
}
$saved = wp_parse_args( $saved, $blogcentral_defaults );
} else {
$saved = $blogcentral_initial;
}
$show_contact = $saved['show_contact'] ? true : false;
$widget_border = $saved['widget_border'] ? $saved['widget_border'] : '';
?>
BlogCentral
BlogCentralPro
";
echo $i;
echo "";
}
}
/**
* Construct the html to upload an image
*
* @since 1.0.0
*
* @param array $opts Optional. Saved options, if any.
* @param string $name Required. Name of the input field.
* @param boolean $background Optional. Construct image for background?
*/
function blogcentral_construct_upload_image( $opts, $name, $background = true ) {
if ( ! isset( $name ) ) {
return;
}
if ( $background ) {
$suffix = '-bck-img';
$suffix_name = '_bck_img';
} else {
$suffix = $suffix_name = '';
}
?>
/>
/>
/>
/>
/>
/>
/>
/>
/>
/>
/>
' . __( 'no border', BLOGCENTRAL_TXT_DOMAIN ) .
'';
for ( $i = 0; $i < 3; ++$i ) {
$select = '';
$html .= "";
}
return $html;
}
/**
* 5.4.2 Font Options
*-----------------------------------------------------------------------*/
/**
* Display font options
*
* @since 1.0.0
*
* @param array $opts Optional. Saved font options
* @param string $name Required. Name to use in constructing the name of the input field.
*/
function blogcentral_display_options_fonts( $opts = '', $name ) {
if ( ! isset( $name ) ) {
return;
}
$system_fonts = array( 'arial', 'baskerville', 'book antiqua', 'century gothic', 'helvetica', 'gill sans',
'impact', 'calibri', 'cambria', 'consolas', 'courier new', 'georgia', 'impact', 'lucida console',
'lucida sans unicode', 'palatino linotype', 'sans serif', 'serif', 'tahoma', 'times new roman',
'trebuchet ms', 'verdana' );
$defaults = array(
$name . "_font_family" => 'no_font',
$name . "_font_type" => 'system',
$name . "_font_weight" => 'regular',
$name . "_font_subsets" => array(),
);
if ( $opts ) {
$opts = wp_parse_args( $opts, $defaults );
} else {
$opts = $defaults;
}
$selected = '';
if ( is_array( $opts ) ) {
$selected = isset( $opts[$name . '_font_family'] ) ? $opts[$name . '_font_family'] : '';
}
// Create nonce for use in the ajax request for a font's options
$nonce = wp_create_nonce( "blogcentral-font-select-nonce" );
$link = admin_url( 'admin-ajax.php?action=blogcentral_font_options&nonce=' . $nonce );
$font_family_select = '';
echo '';
$display = $clean = $system_clean = '';
echo '
';
if ( 'system_fonts' === $type ) {
foreach ( $variants as $key => $val ) {
$select = '';
$font_variants .= ' ';
}
} else {
/*
* If no weights selected, then need a selected font to display its available weights,
* otherwise return.
*/
if ( ! $opts ) {
if ( ! $font ) {
return;
}
$google_fonts = blogcentral_get_google_fonts();
$google_variants = $google_fonts[$font]['variants'];
} else {
$google_variants = $opts;
}
if ( is_array( $google_variants ) && count( $google_variants ) > 0 ) {
foreach ( $google_variants as $variant ) {
$select = '';
$font_variants .= '
';
}
}
}
echo '' . $font_variants . '
';
}
/**
* Construct and display options for font subset
*
* Only if a google font is selected will this be invoked.
*
* @since 1.0.0
*
* @param array $opts Saved subsets options.
* @param string $font Required. Display subsets of font
* @param string $selected Optional. List of saved subsets.
* @param string $name Required. Name to use to construct the name of the input field.
*/
function blogcentral_display_options_subsets( $opts = '', $font, $selected, $name ) {
if ( ! $opts ) {
if ( ! $font ) {
return;
}
$google_fonts = blogcentral_get_google_fonts();
$google_subsets = $google_fonts[$font]['subsets'];
} else {
$google_subsets = $opts;
}
$font_subsets = '
";
}
/**
* Construct and display options for the column layout of a component.
*
* @since 1.0.0
*
* @param string $selected Optional. Saved option for number of columns.
*/
function blogcentral_display_cols_options( $selected = 1 ) {
for ( $i = 1; $i < 5; ++$i ) {
echo "";
}
}
/**
* Construct and display options for social sharing
*
* @since 1.0.0
*
* @param array $opts Optional. Saved options.
* @param object $widget Optional. Widget object if displaying options for a widget.
*/
function blogcentral_display_social_share_opts( $opts, & $widget = false ) {
$name = isset( $opts['name'] ) ? esc_html( $opts['name'] ) : '';
if ( $name ) {
$name = "blogcentral[$name]";
} else {
$name = "blogcentral";
}
echo '
';
}
/**
* 5.4.4 Posts Options
*-----------------------------------------------------------------------*/
/**
* Display general options for posts
*
* @since 1.0.0
*
* @param array $opts Optional. Saved options, if any.
* @param $widget Optional. If set then will use the $widget object's methods
* blogcentral_get_name and get_id to construct the name and id of the input field, respectively.
*/
function blogcentral_display_options_posts_general( $opts, & $widget = false ) {
if ( ! isset( $opts ) ) {
$opts['sticky_display'] = 'on';
}
echo '
';
}
/**
* Display the options for the main posts displayed on the front, archives, categories, tags, and search pages
*
* @since 1.0.0
*
* @param array $opts Optional. Saved options, if any.
* @param $widget Optional. If set then will use the $widget object's methods blogcentral_get_name and get_id to
* construct the name and id of the input field, respectively.
*/
function blogcentral_display_options_posts_landing( $opts, & $widget = false ) {
blogcentral_display_component_layout_options( 'posts_landing', $opts['layout'] );
$opts['name'] = 'posts_landing';
blogcentral_display_component_layout_wraps( $opts, $widget );
blogcentral_display_main_options( $opts, $widget );
blogcentral_display_posts_specific_opts( $opts, $widget );
}
/**
* Display options for the single post page
*
* Can use the same options set for the posts landing page, or override them.
*
* @since 1.0.0
*
* @param array $opts Optional. Saved options, if any.
*/
function blogcentral_display_options_posts_single( $opts ) {
echo "
';
}
/**
* Save custom fields for user
*
* @since 1.0.0
*
* @param int $user_id Required. Id of user.
*/
function blogcentral_save_user_cfs( $user_id ) {
if ( ! isset( $user_id ) ) {
return;
}
$blogcentral_cust_fields = array();
$blogcentral_cust_fields['title'] = sanitize_text_field( $_POST['blogcentral']['title'] );
$blogcentral_cust_fields['contact_facebook'] = esc_url_raw( $_POST['blogcentral']['contact_facebook'] );
$blogcentral_cust_fields['contact_twitter'] = esc_url_raw( $_POST['blogcentral']['contact_twitter'] );
$blogcentral_cust_fields['contact_google'] = esc_url_raw( $_POST['blogcentral']['contact_google'] );
$blogcentral_cust_fields['contact_linkedin'] = esc_url_raw( $_POST['blogcentral']['contact_linkedin'] );
$blogcentral_cust_fields['contact_instagram'] = esc_url_raw( $_POST['blogcentral']['contact_instagram'] );
$blogcentral_cust_fields['contact_tumblr'] = esc_url_raw( $_POST['blogcentral']['contact_tumblr'] );
$blogcentral_cust_fields['contact_pinterest'] = esc_url_raw( $_POST['blogcentral']['contact_pinterest'] );
$blogcentral_cust_fields['items'] = $_POST['blogcentral']['items'];
$blogcentral_cust_fields['avatar'] = esc_url_raw( $_POST['blogcentral']['avatar'] );
$blogcentral_cust_fields['avatar_width'] = absint( $_POST['blogcentral']['avatar_width'] );
$blogcentral_cust_fields['avatar_height'] = absint( $_POST['blogcentral']['avatar_height'] );
$blogcentral_cust_fields['avatar_alt'] = sanitize_text_field( $_POST['blogcentral']['avatar_alt'] );
update_user_meta( $user_id, 'blogcentral_cust_fields', $blogcentral_cust_fields );
}
/**
* 5.7 Admin Ajax
*-----------------------------------------------------------------------*/
/**
* Serves an ajax request to retrieve the font options when a font is selected
*
* @since 1.0.0
*
* @return string json encoded font options.
*/
function blogcentral_font_options() {
if ( ! isset( $_REQUEST['nonce'] ) ) {
return;
}
if ( ! wp_verify_nonce( $_REQUEST['nonce'], "blogcentral-font-select-nonce" ) ) {
exit( __( "No swiping", BLOGCENTRAL_TXT_DOMAIN ) );
}
$result = array();
$json = array();
$font = isset( $_POST['font'] ) ? $_POST['font'] : '';
$name = isset( $_POST['name'] ) ? $_POST['name'] : '';
$type = isset( $_POST['type'] ) ? $_POST['type'] : '';
// Need to call the functions to construct the variants and subsets.
ob_start();
blogcentral_display_options_variants( '', $font, 'regular', $name, $type );
$result['variants'] = ob_get_clean();
// Only google fonts may have subsets.
if ( 'google_fonts' === $type ) {
ob_start();
blogcentral_display_options_subsets( '', $font, '', $name );
$result['subsets'] = ob_get_clean();
}
echo json_encode( $result );
die();
}
/**
* Serves an ajax request to retrieve the template when one is selected
*
* @since 1.0.0
*
* @return string json encoded template.
*/
function blogcentral_display_template_ajax() {
if ( ! isset( $_REQUEST['nonce'] ) ) {
return;
}
if ( ! wp_verify_nonce( $_REQUEST['nonce'], "blogcentral-display-template-nonce" ) ) {
exit( __( "No swiping", BLOGCENTRAL_TXT_DOMAIN ) );
}
$template = isset( $_POST['template'] ) ? $_POST['template'] : '1';
$result = array();
ob_start();
switch( $template ) {
case '1':
// Get the template.
include( locate_template( 'templates/slide-template-1.php', false, false ) );
break;
case '2':
// Get the template.
include( locate_template( 'templates/slide-template-2.php', false, false ) );
break;
case '3':
// Get the template.
include( locate_template( 'templates/slide-template-3.php', false, false ) );
break;
}
$result['template'] = ob_get_clean();
echo json_encode( $result );
die();
}
/**
* Admin ajax error function
*
* @since 1.0.0
*/
function blogcentral_no_go() {
echo __( "No Swiping", BLOGCENTRAL_TXT_DOMAIN );
die();
}
/**
* 6.0 Front End Functions
*-----------------------------------------------------------------------*/
/**
* 6.1 Enqueue Scripts + Inline Scripts
*-----------------------------------------------------------------------*/
/**
* Enqueue all required scripts and styles for the front-end
*
* @since 1.0.0
*/
function blogcentral_enqueue_scripts() {
global $blogcentral_opts;
// Enqueue jquery and jquery ui core.
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core' );
/*
* Add JavaScript to pages with the comment form to support sites with
* threaded comments.
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
// Enqueue flexslider.
wp_enqueue_script( 'flexslider', BLOGCENTRAL_THEME_URL .'/js/jquery.flexslider-min.js', array( 'jquery' ), false, true );
// Enqueue masonry.
wp_enqueue_script( 'masonry', BLOGCENTRAL_THEME_URL . '/js/masonry.pkgd.min.js', array( 'jquery' ), false, false );
// Enqueue waypoints.
wp_enqueue_script( 'waypoints', BLOGCENTRAL_THEME_URL . '/js/jquery.waypoints.min.js', array( 'jquery' ), false, false );
// Enqueue imagesloaded.
wp_enqueue_script( 'imagesloaded', BLOGCENTRAL_THEME_URL . '/js/imagesloaded.pkgd.min.js', array( 'jquery' ), false, true );
// Enqueue jquery easing plugin.
wp_enqueue_script( 'easing', BLOGCENTRAL_THEME_URL . '/js/jquery.easing.1.3.js', array( 'jquery' ), false, true );
// Enqueue front end script.
wp_enqueue_script( BLOGCENTRAL_THEME_PREFIX . '-frontend', BLOGCENTRAL_THEME_URL . '/js/front-end.js', array( 'jquery' ), false, true );
// Enqueue flexslider style.
wp_enqueue_style( 'flexslider-css', BLOGCENTRAL_THEME_URL . '/css/flexslider.css' );
// Enqueue font awesome icons
wp_enqueue_style( 'font-awesome', BLOGCENTRAL_THEME_URL . '/font-awesome/css/font-awesome.min.css' );
// Localize script
$localize = array();
if ( isset( $blogcentral_opts['header_sticky'] ) ) {
$localize['header_sticky'] = $blogcentral_opts['header_sticky'];
}
wp_localize_script( BLOGCENTRAL_THEME_PREFIX . '-frontend' , "blogcentral_object", $localize );
// Load the main stylesheet.
wp_enqueue_style( BLOGCENTRAL_THEME_PREFIX . '-style', get_stylesheet_uri(), array(), '2015-02-10' );
// Enqueue inline css.
$inline_css = blogcentral_enqueue_inline_css();
wp_add_inline_style( 'blogcentral-style', $inline_css );
// Load the responsive stylesheet.
wp_enqueue_style( 'blogcentral-responsive', BLOGCENTRAL_THEME_URL . '/css/responsive.css' );
// Enqueue google fonts.
$protocol = is_ssl() ? 'https' : 'http';
if ( isset( $blogcentral_opts['google_fonts_url'] ) ) {
wp_enqueue_style( 'blogcentral-google-fonts', "$protocol://fonts.googleapis.com/css?family=" . urlencode( $blogcentral_opts['google_fonts_url'] ), array(), null );
}
}
/**
* Enqueue inline css based on the options set on the theme's options page
*
* @since 1.0.0
*/
function blogcentral_enqueue_inline_css() {
// Get the global variable that holds the theme options.
global $blogcentral_opts;
// Initialize variables.
$header_style = $header_link_style = $menu_style = $menu_lnk_style = $menu_lnk_active_style =
$submenu_style = $submenu_lnk_style = $body_style = $link_style = $link_hover_style =
$link_visited_style = $page_header_style = $page_header_style_color = $main_content_style = $headers_style =
$h1_style = $h2_style = $h3_style = $h4_style = $h5_style = $h6_style = $logo_style =
$header_extra_style = $footer_extra_style = $alternate_color_style = $custom_css = $inline_css = '';
// Construct the html fragments for inline css.
// Inline css for the page header.
if ( ! empty( $blogcentral_opts['page_header'] ) ) {
if ( isset( $blogcentral_opts['page_header_color'] ) ) {
$page_header_style_color = 'color:' . esc_html( $blogcentral_opts['page_header_color'] ) . ';';
}
if ( isset( $blogcentral_opts['page_header_bck_img'] ) ) {
$page_header_style .= ' border:none; background-image:url(' .
esc_url( $blogcentral_opts['page_header_bck_img'] ) . ');';
}
if ( isset( $blogcentral_opts['page_header_bck_img_attachment'] ) ) {
$page_header_style .= 'background-attachment:' . esc_html( $blogcentral_opts['page_header_bck_img_attachment'] ) .
';';
}
if ( isset( $blogcentral_opts['page_header_bck_img_position'] ) ) {
$page_header_style .= 'background-position:' . esc_html( $blogcentral_opts['page_header_bck_img_position'] ) .
';';
}
if ( isset( $blogcentral_opts['page_header_bck_img_repeat'] ) ) {
$page_header_style .= 'background-repeat:' . esc_html( $blogcentral_opts['page_header_bck_img_repeat'] ) . ';';
}
if ( isset( $blogcentral_opts['page_header_height'] ) ) {
$page_header_style .= 'height:' . esc_html( $blogcentral_opts['page_header_height'] ) . ';';
}
}
if ( isset( $blogcentral_opts['custom_css'] ) ) {
$custom_css = $blogcentral_opts['custom_css'];
}
// Inline css for the logo.
if ( isset( $blogcentral_opts['logo'] ) && isset( $blogcentral_opts['logo_width'] ) ) {
$logo_style .= "max-width:" . intval($blogcentral_opts['logo_width']) . "px;";
}
// Inline css for the body font.
if ( isset( $blogcentral_opts['fonts']['body_txt_font_family'] ) && 'no_font' !==
$blogcentral_opts['fonts']['body_txt_font_family'] ) {
$body_style .= 'font-family:"' . $blogcentral_opts['fonts']['body_txt_font_family'] . '";';
}
if ( isset( $blogcentral_opts['fonts']['body_txt_font_weight'] ) ) {
$weight = $blogcentral_opts['fonts']['body_txt_font_weight'];
$font_weight = blogcentral_construct_font_weight_style( $weight );
$body_style .= $font_weight['weight'];
if ( isset( $font_weight['style'] ) ) {
$body_style .= $font_weight['style'];
}
}
// Inline css for the main menu font
if ( isset( $blogcentral_opts['fonts']['main_menu_font_family'] ) && 'no_font' !==
$blogcentral_opts['fonts']['main_menu_font_family'] ) {
$menu_style .= 'font-family:"' . $blogcentral_opts['fonts']['main_menu_font_family']. '";';
$menu_lnk_style .= 'font-family:"' . $blogcentral_opts['fonts']['main_menu_font_family'] . '";';
}
if ( isset( $blogcentral_opts['fonts']['main_menu_font_weight'] ) ) {
$weight = $blogcentral_opts['fonts']['main_menu_font_weight'];
$font_weight = blogcentral_construct_font_weight_style( $weight );
$menu_style .= $font_weight['weight'];
$menu_lnk_style .= $font_weight['weight'];
if ( isset( $font_weight['style'] ) ) {
$style = $font_weight['style'];
$menu_style .= $style;
$menu_lnk_style .= $style;
}
}
// Inline css for the headers font.
if ( isset( $blogcentral_opts['fonts']['headers_font_family'] ) && 'no_font' !==
$blogcentral_opts['fonts']['headers_font_family'] ) {
$headers_style .= 'font-family:"' . $blogcentral_opts['fonts']['headers_font_family'] . '";';
}
if ( isset( $blogcentral_opts['fonts']['headers_font_weight'] ) ) {
$weight = $blogcentral_opts['fonts']['headers_font_weight'];
$font_weight = blogcentral_construct_font_weight_style( $weight );
$headers_style .= $font_weight['weight'];
if ( isset( $font_weight['style'] ) ) {
$style = $font_weight['style'];
$headers_style .= $style;
}
}
// Inline css for the body.
if ( isset( $blogcentral_opts['body_txt_color'] ) ) {
$body_style .= 'color:' . $blogcentral_opts['body_txt_color'] . ';';
}
if ( isset( $blogcentral_opts['body_bck_img'] ) ) {
$body_style .= 'background-image:url(' . $blogcentral_opts['body_bck_img'] . ');';
if ( isset( $blogcentral_opts['body_bck_img_attachment'] ) ) {
$body_style .= 'background-attachment:' . $blogcentral_opts['body_bck_img_attachment'] . ';';
}
if ( isset( $blogcentral_opts['body_bck_img_position'] ) ) {
$body_style .= 'background-position:' . $blogcentral_opts['body_bck_img_position'] . ';';
}
if ( isset( $blogcentral_opts['body_bck_img_repeat'] ) ) {
$body_style .= 'background-repeat:' . $blogcentral_opts['body_bck_img_repeat'] . ';';
}
} elseif ( isset( $blogcentral_opts['body_back_color'] ) ) {
$body_style .= 'background-color:' . $blogcentral_opts['body_back_color'] . ';';
}
if ( isset( $blogcentral_opts['body_lnk_color'] ) ) {
$link_style .= 'color:' . $blogcentral_opts['body_lnk_color'] . ';';
}
if ( isset( $blogcentral_opts['body_lnk_hover_color'] ) ) {
$link_hover_style .= 'color:' . $blogcentral_opts['body_lnk_hover_color'] . ';';
}
if ( isset( $blogcentral_opts['body_lnk_visited_color'] ) ) {
$link_visited_style .= 'color:' . $blogcentral_opts['body_lnk_visited_color'] . ';';
}
// Inline css for the main content.
if ( isset( $blogcentral_opts['main_content_back_color'] ) ) {
$main_content_style .= 'background-color:' . $blogcentral_opts['main_content_back_color'] . ';';
}
// Inline css for the header.
if ( isset( $blogcentral_opts['header_back_color'] ) ) {
$header_style .= 'background-color:' . $blogcentral_opts['header_back_color'] . ';';
}
if ( isset( $blogcentral_opts['header_lnk_color'] ) ) {
$header_link_style .= 'color:' . $blogcentral_opts['header_lnk_color'] . ';';
}
if ( isset( $blogcentral_opts['header_txt_color'] ) ) {
$header_style .= 'color:' . $blogcentral_opts['header_txt_color'] . ';';
$header_extra_style .= 'color:' . $blogcentral_opts['header_txt_color'] . ';';
}
// Inline css for the menu.
if ( isset( $blogcentral_opts['menu_lnk_color'] ) ) {
$menu_lnk_style .= 'color:' . $blogcentral_opts['menu_lnk_color'] . ';';
$menu_style .= 'color:' . $blogcentral_opts['menu_lnk_color'] . ';';
}
if ( isset( $blogcentral_opts['menu_back_color'] ) ) {
$menu_style .= 'background-color:' . $blogcentral_opts['menu_back_color'] . ';';
}
if ( isset( $blogcentral_opts['menu_active_color'] ) ) {
$menu_lnk_active_style .= 'color:' . $blogcentral_opts['menu_active_color'] . ';';
}
// Inline css for the submenu.
if ( isset( $blogcentral_opts['submenu_back_color'] ) ) {
$submenu_style .= 'background-color:' . $blogcentral_opts['submenu_back_color'] . ';';
}
if ( isset( $blogcentral_opts['submenu_lnk_color'] ) ) {
$submenu_lnk_style .= 'color:' . $blogcentral_opts['submenu_lnk_color'] . ';';
}
// Inline css for the headers.
if ( isset( $blogcentral_opts['h1']['size'] ) ) {
$h1_style .= 'font-size:' . $blogcentral_opts['h1']['size'] . ' !important;';
}
if ( isset( $blogcentral_opts['h1']['color'] ) ) {
$h1_style .= 'color:' . $blogcentral_opts['h1']['color'] . ';';
}
if ( isset( $blogcentral_opts['h2']['size'] ) ) {
$h2_style .= 'font-size:' . $blogcentral_opts['h2']['size'] . ' !important;';
}
if ( isset( $blogcentral_opts['h2']['color'] ) ) {
$h2_style .= 'color:' . $blogcentral_opts['h2']['color'] . ' !important;';
}
if ( isset( $blogcentral_opts['h3']['size'] ) ) {
$h3_style .= 'font-size:' . $blogcentral_opts['h3']['size'] . ' !important;';
}
if ( isset( $blogcentral_opts['h3']['color'] ) ) {
$h3_style .= 'color:' . $blogcentral_opts['h3']['color'] . ' !important;';
}
if ( isset( $blogcentral_opts['h4']['size'] ) ) {
$h4_style .= 'font-size:' . $blogcentral_opts['h4']['size'] . ' !important;';
}
if ( isset( $blogcentral_opts['h4']['color'] ) ) {
$h4_style .= 'color:' . $blogcentral_opts['h4']['color'] . ';';
}
if ( isset( $blogcentral_opts['h5']['size'] ) ) {
$h5_style .= 'font-size:' . $blogcentral_opts['h5']['size'] . ' !important;';
}
if ( isset( $blogcentral_opts['h5']['color'] ) ) {
$h5_style .= 'color:' . $blogcentral_opts['h5']['color'] . ';';
}
if ( isset( $blogcentral_opts['h6']['size'] ) ) {
$h6_style .= 'font-size:' . $blogcentral_opts['h6']['size'] . ' !important;';
}
if ( isset( $blogcentral_opts['h6']['color'] ) ) {
$h6_style .= 'color:' . $blogcentral_opts['h6']['color'] . ';';
}
// Now put all the html fragments together.
$sep = '';
if ( $page_header_style ) {
$inline_css .= $sep . "#precontent-widget, #precontent-widget-cont{ $page_header_style }";
$sep = ' ';
}
if ( $page_header_style_color ) {
$inline_css .= $sep . "#precontent-widget-cont,#precontent-widget-cont h1,#precontent-widget-cont h2, #precontent-widget-cont h3, #precontent-widget-cont h4, #precontent-widget-cont h5, #precontent-widget-cont h6, #precontent-widget-cont a { $page_header_style_color }";
$sep = ' ';
}
if ( $logo_style ) {
$inline_css .= $sep . "#logo img { $logo_style }";
$sep = ' ';
}
if ( $body_style ) {
$inline_css .= $sep . "body { $body_style }";
$sep = ' ';
}
if ( $main_content_style ) {
$inline_css .= $sep . "#main-content{ $main_content_style }";
$sep = ' ';
}
if ( $link_style ) {
$inline_css .= $sep . "a { $link_style }";
$sep = ' ';
}
if ( $link_hover_style ) {
$inline_css .= $sep . "a:hover { $link_hover_style}";
$sep = ' ';
}
if ( $link_visited_style ) {
$inline_css .= $sep . "a:visited { $link_visited_style }";
$sep = ' ';
}
if ( $h1_style ) {
$inline_css .= $sep . "h1 { $h1_style }";
$sep = ' ';
}
if ( $h2_style ) {
$inline_css .= $sep . "h2{ $h2_style }";
$sep = ' ';
}
if ( $h3_style ) {
$inline_css .= $sep . "h3{ $h3_style }";
$sep = ' ';
}
if ( $h4_style ) {
$inline_css .= $sep . "h4 { $h4_style }";
$sep = ' ';
}
if ( $h5_style ) {
$inline_css .= $sep . "h5 { $h5_style }";
$sep = ' ';
}
if ( $h6_style ) {
$inline_css .= $sep . "h6 { $h6_style }";
$sep = ' ';
}
if ( $headers_style ) {
$inline_css .= $sep . "h1,h2,h3,h4,h5,h6,.footer h1,.footer h2,.footer h3,.footer h4,.footer h5,.footer h6,.footer .post-title a{ $headers_style }";
$sep = ' ';
}
if ( $header_style ) {
$inline_css .= $sep . "#header { $header_style }";
$sep = ' ';
}
if ( $header_link_style ){
$inline_css .= $sep . "#header a { $header_link_style }";
$sep = ' ';
}
if ( $header_extra_style ) {
$inline_css .= $sep . "#header .fa{ $header_extra_style }";
$sep = ' ';
}
if ( $menu_style ) {
$inline_css .= $sep . "#access { $menu_style }";
$sep = ' ';
}
if ( $menu_lnk_style ) {
$inline_css .= $sep . "#access a { $menu_lnk_style }";
$sep = ' ';
}
if ( $menu_lnk_active_style ) {
$inline_css .= $sep . "#access .current_page_item > a { $menu_lnk_active_style }";
$sep = ' ';
}
if ( $submenu_style ) {
$inline_css .= $sep . "#access ul ul li { $submenu_style }";
$sep = ' ';
}
if ( $submenu_lnk_style ) {
$inline_css .= $sep . "#access ul ul a{ $submenu_lnk_style }";
$sep = ' ';
}
$footer_style = $footer_link_style = $footer_link_hover_style = $footer_link_visited_style = $menu_style =
$menu_lnk_style = $submenu_style = $submenu_lnk_style = '';
// Inline css for the footer.
if ( isset( $blogcentral_opts['footer_bck_color'] ) ) {
$footer_style .= 'background-color:' . $blogcentral_opts['footer_bck_color'] . ';';
}
if ( isset( $blogcentral_opts['footer_txt_color'] ) ) {
$footer_style .= 'color:' . $blogcentral_opts['footer_txt_color'] . ';';
$footer_extra_style .= 'color:' . $blogcentral_opts['footer_txt_color'] . ' !important;';
}
if ( isset( $blogcentral_opts['footer_lnk_color'] ) ) {
$footer_link_style .= 'color:' . $blogcentral_opts['footer_lnk_color'] . ';';
}
if ( isset( $blogcentral_opts['footer_lnk_hover_color'] ) ) {
$footer_link_hover_style .= 'color:' . $blogcentral_opts['footer_lnk_hover_color'] . ';';
}
if ( isset( $blogcentral_opts['footer_lnk_visited_color'] ) ) {
$footer_link_visited_style .= 'color:' . $blogcentral_opts['footer_lnk_visited_color'] . ';';
}
if ( $footer_style ) {
$inline_css .= $sep . ".footer { $footer_style }";
$sep = ' ';
}
if ( $footer_link_style ) {
$inline_css .= $sep . ".footer a { $footer_link_style }";
$sep = ' ';
}
if ( $footer_link_hover_style ) {
$inline_css .= $sep . ".footer a:hover { $footer_link_hover_style }";
$sep = ' ';
}
if ( $footer_link_visited_style ) {
$inline_css .= $sep . ".footer a:visited { $footer_link_visited_style }";
$sep = ' ';
}
if ( $footer_extra_style ) {
$inline_css .= $sep . ".footer h1,.footer h2, .footer h3, .footer .post-title a, .footer h4,.footer h5,.footer h5, .footer .fa{ $footer_extra_style }";
$sep = ' ';
}
if ( $custom_css ) {
$inline_css .= $sep . $custom_css;
}
// Inline css for the slide templates.
$inline_css .= $sep . ".slide-template {
background-image: url(" . BLOGCENTRAL_THEME_URL . "/images/placeholder.png); }
.slide-template-2 {
background-image: url(" . BLOGCENTRAL_THEME_URL . "/images/placeholder.png);
}";
return $inline_css;
}
/**
* 6.2 Fonts
*-----------------------------------------------------------------------*/
/**
* Construct and display css for saved weight and style font options
*
* @since 1.0.0
*
* @param string $weight Required. Weight value for font and maybe style.
* @return array. Contains css for weight and style options indexed by weight and style, respectively.
*/
function blogcentral_construct_font_weight_style( $weight ) {
$frag = array();
if ( 'regular' === $weight ) {
$weight = '400';
}
if ( 'italic' === $weight ) {
$weight = '400italic';
}
$frag['weight'] = 'font-weight:' . esc_html( substr( $weight, 0 ,3 ) ) . ';';
$font_length = strlen( $weight );
/*
* Example of weight: 400italic. The first 3 characters always represents the font weight.
* If length is greater than 3, then has a font style.
*/
if ( 3 < $font_length ) {
if ( $font_style = substr( $weight, 3, $font_length-3 ) ) {
$frag['style'] = 'font-style:' . esc_html( $font_style ) . ';';
}
}
return $frag;
}
// Need to remove this filter since the description is used in the meta tag content attribute, and no
tags are allowed.
remove_filter( 'term_description', 'wpautop' );
/**
* 6.3 Construct meta tags
*-----------------------------------------------------------------------*/
/**
* Construct the meta tags to be added to the header
*
* Construct static and dynamic meta tags.
*
* @since 1.0.0
*/
function blogcentral_construct_meta_tag() {
echo '';
}
/**
* 6.4 Body Class
*-----------------------------------------------------------------------*/
/**
* Construct the classes to be added to the body tag
*
* Uses the body_class filter.
*
* @since 1.0.0
*
* @param array $classes Required. Array of classes.
* @return array $classes. Classes to be added to the body tag, augmented with the theme's classes.
*/
function blogcentral_body_class( $classes ) {
// Global variable that holds the theme options.
global $blogcentral_opts;
if ( ! is_multi_author() ) {
$classes[] = 'single-author';
}
if ( is_active_sidebar( 'sidebar-rght' ) && ! is_attachment() && ! is_404() ) {
$classes[] = 'sidebar';
}
if ( ! get_option( 'show_avatars' ) ) {
$classes[] = 'no-avatars';
}
if ( isset( $blogcentral_opts['color_scheme'] ) ) {
$scheme = $blogcentral_opts['color_scheme'];
}
if ( isset( $scheme ) && 'none' !== $scheme ) {
$classes[] = 'color-scheme' . esc_html( $scheme );
}
$classes[] = ' color-scheme';
if ( isset( $blogcentral_opts['block_display'] ) ) {
$classes[] = 'block-display';
}
if ( isset( $blogcentral_opts['box_display'] ) ) {
$classes[] = 'box-display';
}
return $classes;
}
/**
* 6.5 Page Header/Precontent Area
*-----------------------------------------------------------------------*/
/**
* Display today's date
*
* @since 1.0.0
*/
function blogcentral_get_todays_date() {
print strftime('%A %B %d, %Y');
}
/**
* Construct and display the breadcrumbs
*
* @since 1.0.0
*/
function blogcentral_the_breadcrumbs() {
global $post;
// If on home page, no need to display the breadcrumbs.
if ( is_home() ) {
return '';
}
echo '
';
// Link to home will be displayed first.
echo '
comment_type ) :
case 'pingback' :
case 'trackback' :
?>
', '' ); ?>
id="li-comment-">
* @return array that contains the before and after tags for a component.
*/
function blogcentral_construct_wrapper( $wrapper ) {
if ( ! isset( $wrapper ) ) {
return;
}
$wrapper_class = isset( $wrapper['wrapper_class'] ) ? esc_attr( $wrapper['wrapper_class'] ) : '';
$wrapper_style = isset( $wrapper['wrapper_style'] ) ? $wrapper['wrapper_style'] : '';
$title_class = isset( $wrapper['title_class'] ) ? esc_attr( $wrapper['title_class'] ) : '';
// Do not escape the title_text and tagline because html markup is allowed in these.
$title_text = isset( $wrapper['title_text'] ) ? html_entity_decode( $wrapper['title_text'] ) : '';
$tagline = isset( $wrapper['tagline_text'] ) ? html_entity_decode( $wrapper['tagline_text'] ) : '';
$tagline_class = isset( $wrapper['tagline_class'] ) ? esc_attr( $wrapper['tagline_class'] ) : '';
$class = '';
$before = $after = '';
$before = '
';
// Add title and tagline texts to component.
if ( $title_text ) {
$extra_title = '';
$before .= '
' . $title_text . '
';
$before .= '
';
if ( $tagline ) {
$before .= '
' . __( $tagline, BLOGCENTRAL_TXT_DOMAIN ) .
'
';
}
$before .= '
';
}
$after = '';
return array( $before, $after );
}
/**
* Wrapper function to create common template beginning and ending tags
*
* @since 1.0.0
*
* @param array $opts Required. Various options set on the theme's options page
* @return array. Contains the html fragments for the beginning and ending wrapper
s.
*/
function blogcentral_common_template_wrapper( $opts ) {
$classes = blogcentral_construct_wrapper_classes_styles( $opts );
$wrapper = array(
'wrapper_class' => "components-wrap$classes[layout_class]$classes[wrap_class]",
'wrapper_style' => $classes['wrap_style'],
'title_text' => isset( $opts['title_text'] ) ? $opts['title_text'] : '',
'tagline_text' => isset( $opts['tagline_text'] ) ? $opts['tagline_text'] : '',
'title_class' => "$classes[title_class] $classes[extra_class]",
'tagline_class' => $classes['extra_tagline']
);
$frag = blogcentral_construct_wrapper( $wrapper );
return $frag;
}
/**
* Construct html for the classes and styles of the various containers in the component, eg. media wrap, and meta/content wrap
*
* @since 1.0.0
*
* @param array $opts Required. Various options for the containers, set on the theme's options page
* @return array. Contains the html fragments for classes and styles of the various containers in a component.
*/
function blogcentral_construct_inner_classes_styles( $opts ) {
// Initialize variables
$blogcentral_media_wrap_style = $blogcentral_li_wrap_style = $blogcentral_component_item_style =
$align_style = $blogcentral_meta_wrap_class = $blogcentral_meta_wrap_style = $blogcentral_extra_li_class =
$layout_class = $layout = $cols_span = $cols = $post_meta_layout = '';
extract( $opts );
$blogcentral_extra_li_class .= ' component';
// Add classes to implement the layout of the component item.
if ( 'layout3' === $layout ) {
$layout_class .= ' layout1';
}
if ( $layout_class || isset( $layout ) && '1' !== $layout && '2' !== $layout ) {
$blogcentral_extra_li_class .= ' ' . esc_attr( $layout ) . $layout_class;
}
// Add class for post meta layout.
if ( '2' === $post_meta_layout ) {
$blogcentral_meta_wrap_class .= " meta-layout2";
}
if ( $blogcentral_li_wrap_style || $blogcentral_component_item_style ) {
$blogcentral_component_item_style = " style='" . trim( $blogcentral_li_wrap_style ) . trim( $blogcentral_component_item_style ) . "'";
}
return compact( "blogcentral_component_item_style", "blogcentral_li_wrap_style", "blogcentral_media_wrap_style", "blogcentral_meta_wrap_class", "blogcentral_meta_wrap_style", "blogcentral_extra_li_class" );
}
/**
* Construct html for masonry display
*
* @since 1.0.0
*
* @param array $opts Required. Options for the masonry display.
* @return string. Contains the html for masonry display.
*/
function blogcentral_construct_masonry_options( $opts ) {
$selector = $col_width = '';
extract( $opts );
if ( isset( $cols ) ) {
$col_width = ".cols-$cols-sizer";
}
return '{ "columnWidth": "' . esc_attr( $col_width ) . '" "itemSelector": "' . esc_attr( $selector ) . '", "gutter": "' . esc_attr( $gutter ) . '" }';
}