for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Add title-tag support.
add_theme_support( "title-tag" );
/**
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
// This theme supports custom background color and image.
add_theme_support( 'custom-background' );
// This theme supports the following post formats by default.
add_theme_support( 'post-formats', array( 'audio', 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', ) );
// Support post thumbnails.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 604, 270, true );
}
}
if ( ! function_exists( 'blogcentral_register_widgets_areas' ) ) {
/**
* Register widgetized areas
*
* @since 1.0.0
*/
function blogcentral_register_widgets_areas() {
$extra_class = '';
global $blogcentral_opts;
// Add class for default widget border, if set
if ( isset( $blogcentral_opts['widget_border'] ) ) {
$extra_class .= ' ' . $blogcentral_opts['widget_border'];
}
register_sidebar( array(
'name' => __( 'Header Widget', BLOGCENTRAL_TXT_DOMAIN ),
'id' => 'header-widget',
'description' => __( 'Widgets in this area will be shown in the header area if layout is 2, to the
left of the logo. Ideal for advertisement banner or search form. The size is 77%
by 50px.', BLOGCENTRAL_TXT_DOMAIN ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
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 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 options page. For more detailed
information, consult the readme.txt file and the theme\'s online documentation at http://4bzthemes/knowledgebase', BLOGCENTRAL_TXT_DOMAIN ) . ' ' . __( 'Documentation on ', BLOGCENTRAL_TXT_DOMAIN ) . BLOGCENTRAL_THEME_NAME . '.' .
'
' . __( 'Demos', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'BlogCentral provides 3 predefined demos to choose. The demos define values for some of the theme options. Choosing a demo should be the first step, since it will delete all of your saved options. When you select the demo you would like to use, immediately click on the "Change Demo" button, this will save the demo options as the theme options. You can further customize the options, if desired, by using the theme options page. The demo settings, just like the theme options, if applicable, will apply to all pages.', BLOGCENTRAL_TXT_DOMAIN ) . '
' .
'
' . __( 'Making your site look like the demos', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'Your site will almost look exactly like the demos except for maybe, your logo, posts, and widgets. You can download an xml file for the demo content, which will include the posts. For the widgets, you will have to download the widgets.json file, and have the Widget Import/Export plugin installed and activated. For more detailed information read this tutorial.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'BlogCentral provides page templates used to demonstrate the demos. You have the choice to use them or not, but if you do, please read the following. Whenever a user chooses a demo to view on the front end, its options will be the active theme options, until the home page, or another demo is chosen on the front end, for example from the main navigation menu. If you change the theme options on the admin side, and do not see these changes on the front end, you will have to navigate to the home page, effectively changing the options from the previously viewed demo, to the options saved from the theme options page.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
}
if ( ! function_exists( 'blogcentral_construct_contact_help_tab' ) ) {
/**
* Construct help panel for the contact tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_contact_help_tab() {
$html = '
' . __( 'Icons', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'To choose an icon, click inside the input textbox.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( '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;
}
}
if ( ! function_exists( 'blogcentral_construct_typography_help_tab' ) ) {
/**
* 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;
}
}
if ( ! function_exists( 'blogcentral_construct_social_api_help_tab' ) ) {
/**
* 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;
}
}
if ( ! function_exists( 'blogcentral_construct_colors_help_tab' ) ) {
/**
* Construct help panel for the general tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_colors_help_tab() {
$html = '
' . __( 'The "General Background, Colors, & Sizes" tab is where you can choose a color scheme, customize the color for the body text, links, and headers, the background color for the main content, and the size of the header tags.', 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 ) . '
' . __( '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;
}
}
if ( ! function_exists( 'blogcentral_construct_header_help_tab' ) ) {
/**
* Construct help panel for the header tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_header_help_tab() {
$html = '
' . __( 'The "Header" tab is where you customize the appearance of the header. The header is the top area of the page that holds the logo, header widget, and the main navigation menu.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'Contact Information Display', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'BlogCentral provides options to display the contact information for a company or an individual. If you would like to display the contact information, the BlogCentral Shortcodes & Widgets Pack plugin must be installed and activated. 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;
}
}
if ( ! function_exists( 'blogcentral_construct_nav_menu_help_tab' ) ) {
/**
* Construct help panel for the header tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_nav_menu_help_tab() {
$html = '
' . __( 'The "Main Navigation Menu" tab is where you customize the appearance of the main navigation menu and its submenus. You can customize the color for the background, links, and active links.', BLOGCENTRAL_TXT_DOMAIN ) . '
';
return $html;
}
}
if ( ! function_exists( 'blogcentral_construct_page_header_help_tab' ) ) {
/**
* Construct help panel for the page header tab
*
* @since 1.0.0
*
* @return string help instructions.
*/
function blogcentral_construct_page_header_help_tab() {
$html = '
' . __( 'The "Page Header" tab is where you customize the appearance of the page header. The page header sits immediately below the header. This area is widgetized and is also called the precontent widget. If no widgets are active, then it serves as the page header and a box with an image and an overlay that shows what page is being viewed, today\'s date, and the breadcrumbs will be shown, if enabled.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'Height', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'You can define a height for the page header, enter it with the unit of measurement, ex. 150px.', BLOGCENTRAL_TXT_DOMAIN ) . '
' . __( 'These options will affect the appearance of the posts listing in the main area on all pages that display a posts listing in a div with id #main-area, eg. index, 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 posts listing 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
*-----------------------------------------------------------------------*/
if ( ! function_exists( 'blogcentral_front_controller' ) ) {
/**
* 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
}
}
if ( ! function_exists( 'blogcentral_validate_options' ) ) {
/**
* 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( "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", "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;
}
}
if ( ! function_exists( 'blogcentral_admin_notices' ) ) {
/**
* Output any admin notices
*
* @since 1.0.0
*/
function blogcentral_admin_notices() {
settings_errors();
}
}
if ( ! function_exists( 'blogcentral_change_blog_demo' ) ) {
/**
* Change the 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 demo', BLOGCENTRAL_TXT_DOMAIN ) );
return;
}
if ( '0' === $template ) {
$_POST['messages'] = array( __( "If you do not want to use a 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( __( 'Demo Changed Successfully!', BLOGCENTRAL_TXT_DOMAIN ) );
}
}
}
/**
* 5.4 Theme Options
*-----------------------------------------------------------------------*/
/**
* 5.4.1 Main
*-----------------------------------------------------------------------*/
if ( ! function_exists( 'blogcentral_get_field_name_wrap' ) ) {
/**
* Construct name of input field for use on the theme options page, and if the BlogCental Shortcodes & Widgets Pack plugin is installed, on the 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 );
}
}
if ( ! function_exists( 'blogcentral_get_field_id_wrap' ) ) {
/**
* Construct id for use on the theme options page, and if the BlogCental Shortcodes & Widgets Pack plugin is installed, on the 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 );
}
}
if ( ! function_exists( 'blogcentral_register_theme_options' ) ) {
/**
* 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' );
}
}
if ( ! function_exists( 'blogcentral_theme_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'] : '';
?>
";
echo $i;
echo "";
}
}
}
if ( ! function_exists( 'blogcentral_construct_upload_image' ) ) {
/**
* 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
*-----------------------------------------------------------------------*/
if ( ! function_exists( 'blogcentral_display_options_fonts' ) ) {
/**
* 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 . '
';
}
}
if ( ! function_exists( 'blogcentral_display_options_subsets' ) ) {
/**
* 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 = '
";
// If displaying options for the single post page, do not display these options.
if ( 'posts_single' !== $name ) :
echo "
" . __( 'How many columns?', BLOGCENTRAL_TXT_DOMAIN ) . "
";
_e( 'Note: the number of columns shown may change due to the size of the screen and/or the layout chosen for the posts. Layout 2, at the most, will be displayed in 2 columns, even if you choose 3 or 4 columns.', BLOGCENTRAL_TXT_DOMAIN );
echo "
";
endif;
echo "
" . __( 'Border for each post', BLOGCENTRAL_TXT_DOMAIN ) . "
";
// If displaying options for the single post page, do not display these options
if ( 'posts_single' !== $name ) :
echo "
";
_e( 'Separate classes with a space.', BLOGCENTRAL_TXT_DOMAIN );
echo "
";
}
}
if ( ! function_exists( 'blogcentral_display_cols_options' ) ) {
/**
* 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 "";
}
}
}
if ( ! function_exists( 'blogcentral_display_social_share_opts' ) ) {
/**
* 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
*-----------------------------------------------------------------------*/
if ( ! function_exists( 'blogcentral_display_options_posts_general' ) ) {
/**
* 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 '
';
}
}
if ( ! function_exists( 'blogcentral_display_options_posts_landing' ) ) {
/**
* 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 );
}
}
if ( ! function_exists( 'blogcentral_display_options_posts_single' ) ) {
/**
* 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 "
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 ) {
$before .= '
' . $title_text . '
';
$before .= '
';
if ( $tagline ) {
$before .= '
' . $tagline . '
';
}
$before .= '
';
}
$after = '';
return array( $before, $after );
}
}
if ( ! function_exists( 'blogcentral_common_template_wrapper' ) ) {
/**
* 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;
}
}
if ( ! function_exists( 'blogcentral_construct_inner_classes_styles' ) ) {
/**
* 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" );
}
}
if ( ! function_exists( 'blogcentral_construct_masonry_options' ) ) {
/**
* 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 ) . '" }';
}
}