> Widgets screen.
*/
function admin_notice_widgets()
{
// Let the Developers know how many widgetized areas are active -
// only on the Appearance >> Widgets screen.
if ( \ski\question::is_admin_screen( 'widgets' ) )
{
// OPTION: Display top
$opt_top = get_theme_mod( 'bpq_opt_format_display_top', 1 );
$num_top = empty( $opt_top ) ? 0 : 1;
// OPTION: Split masthead
$opt_masthead_split = get_theme_mod( 'bpq_opt_masthead_use_widgets', 0 );
$num_masthead = empty( $opt_masthead_split ) ? 0 : 1;
// OPTION: Number of sidebar sections
$opt_sidebars = get_theme_mod( 'bpq_opt_format_sidebar_layout', 'r1' );
$num_sidebars = convert_symbol_sidebar_layout( $opt_sidebars );
// OPTION: Display pedestal
$opt_pedestal = get_theme_mod( 'bpq_opt_format_display_pedestal', 1 );
// OPTION: Number of pedestal sections
$opt_pedestals = get_theme_mod( 'bpq_opt_pedestal_sections', '3' );
$num_pedestals = empty( $opt_pedestal ) ? 0 : intval( $opt_pedestals );
// OPTION: Display bottom
$opt_bottom = get_theme_mod( 'bpq_opt_format_display_bottom', 1 );
$num_bottom = empty( $opt_bottom ) ? 0 : 1;
// Markup goes inside of a
with class 'updated', per WP.
echo
'
'.
'
'.
sprintf(
__(
'BluePrint-Q supports multiple widgetized areas. '.
'To change which areas are displayed, please go to the '.
'Theme Customizer.
'.
'You are currently displaying the following: '.
' '.
'Top %d of 1'.
' · Masthead %d of 1'.
' · Sidebars %d of 2'.
' · Pedestal %d of 6'.
' · Bottom %d of 1',
'bpq'
),
admin_url( 'customize.php' ),
$num_top,
$num_masthead,
$num_sidebars,
$num_pedestals,
$num_bottom
).
'
'.
'
';
}
// We also want to remind Developers that to get Bootstrap styling
// for their Contact Form 7 forms, they must embed the Bootstrap
// markup directly into their form just like it were HTML -
// only on the Contact Form 7 admin screens.
elseif ( \ski\question::is_admin_screen( 'toplevel_page_wpcf7' ) )
{
echo
'
'.
'
'.
sprintf(
__(
'To ensure that your Contact Forms have styles that align with '.
'the rest of your site, please use markup as detailed in the '.
'Bootstrap documentation.',
'bpq'
),
'http://getbootstrap.com/css/#forms'
).
'
'.
'
';
}
}
/**
* Registers custom widgets that are specially created for BluePrint-Q.
*/
function register_custom_widgets()
{
register_widget( 'bpq\widget_cf7' );
register_widget( 'bpq\widget_menu' );
register_widget( 'bpq\widget_profile' );
}
/**
* Registers all widgetized areas for use in the Top area.
*/
function register_top_widgetized_areas()
{
// There is one widgetized area for the top.
$desc = __( 'Displays content along the top of the site. BluePrint-Q recommends horizontal layouts without titles for this area.', 'bpq' );
register_sidebar( array(
'name' => __( 'Top', 'bpq' ),
'id' => 'top-1',
'description' => $desc,
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
}
/**
* Registers all widgetized areas for use in the Masthead area.
*/
function register_masthead_widgetized_areas()
{
// There is a single static area for a logo/tagline and a potential widgetized area next to it.
$desc = __( 'Displays additional content alongside the masthead.', 'bpq' );
register_sidebar( array(
'name' => __( 'Masthead', 'bpq' ),
'id' => 'masthead-1',
'description' => $desc,
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
}
/**
* Registers all widgetized areas for use in the Content area.
*/
function register_sidebar_widgetized_areas()
{
// OPTION: Number of sidebar sections
$opt_sidebars = get_theme_mod( 'bpq_opt_format_sidebar_layout', 'r1' );
$num_sidebars = convert_symbol_sidebar_layout( $opt_sidebars );
// There are two sidebars, at most - the first one will appear
// when there is a layout of exactly one sidebar or will appear
// on the left when a layout of two sidebars has been selected.
$desc = __( 'Displays widget content in a column between the header/footer.', 'bpq' );
if ( $num_sidebars >= 2 ) $desc = __( 'Displays widget content in a column between the header/footer to the left of Sidebar #2.', 'bpq' );
register_sidebar( array(
'name' => __( 'Sidebar #1', 'bpq' ),
'id' => 'sidebar-1',
'description' => $desc,
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
// The second sidebar will only appear when a layout of exactly two
// sidebars has been selected and it will always appear on the right.
$desc = __( 'Displays widget content in a column between the header/footer to the right of Sidebar #1.', 'bpq' );
register_sidebar( array(
'name' => __( 'Sidebar #2', 'bpq' ),
'id' => 'sidebar-2',
'description' => $desc,
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
}
/**
* Registers all widgetized areas for use in the Pedestal area.
*/
function register_pedestal_widgetized_areas()
{
// OPTION: Number of pedestal sections
$opt_pedestals = get_theme_mod( 'bpq_opt_pedestal_sections', '3' );
$num_pedestals = intval( $opt_pedestals );
// Since there is potential to have a large number of widget areas
// in the Pedestal section, loop through the areas desired to
// register each instead of writing each out.
for( $i = 1; $i <= 6; $i++ )
{
// Shortcuts that typically use the increment.
$name = sprintf( __( 'Pedestal #%d', 'bpq' ), $i );
$id = sprintf( 'pedestal-%d', $i );
$description = sprintf ( __( 'Displays widget content to the right of Pedestal #%d.', 'bpq' ), ( $i - 1 ) );
// Change the description to better fit the settings context.
if ( $i == 1 )
{
$description = ( $num_pedestals == 1 )
? __( 'Displays widget content across the entire width of the footer.', 'bpq' )
: __( 'Displays widget content on the far-left side of the footer.', 'bpq' );
}
// Now that we have the info required, perform the registration.
register_sidebar( array(
'name' => $name,
'id' => $id,
'description' => $description,
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
}
}
/**
* Registers all widgetized areas for use in the Bottom area.
*/
function register_bottom_widgetized_areas()
{
// There is one widgetized area for the bottom.
$desc = __( 'Displays content along the bottom of the site. BluePrint-Q recommends horizontal layouts without titles for this area.', 'bpq' );
register_sidebar( array(
'name' => __( 'Bottom', 'bpq' ),
'id' => 'bottom-1',
'description' => $desc,
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'
));
}
/**
* Social buttons can typically require additional markup
* that is placed once on a page.
* @link https://developers.facebook.com/docs/plugins/like-button
* @link https://developers.google.com/+/web/+1button/
*/
function add_social_prerequisites()
{
// Facebook 'like' button.
echo
'
'.
'';
// Google '+1' button.
echo
'';
// Pinterest.
echo
'';
// StumbleUpon.
echo
'';
}
/**
* Converts the symbolic value of the sidebar layout to a number
* that indicates how many sidebars were selected.
* @param type $symbol A symbol like '0', 'l1', 'l2', 'l1r1', 'r2', or 'r1'
* @return string The desired number like 0, 1, or 2
*/
function convert_symbol_sidebar_layout( $symbol )
{
switch ( $symbol )
{
case 'l1':
case 'r1':
return 1;
break;
case 'l2':
case 'l1r1':
case 'r2':
return 2;
default:
return 0;
}
}
/**
* Ensures that the args used for the widgets are the same
* across all widgets - from WP and custom.
*
* Note: The params is a two-dim array that might look something like this:
* (
* [0] => Array
* (
* [name] => Sidebar #1
* [id] => 'sidebar-1'
* [description] => Displays widget content in a column between the header/footer.
* [class] =>
* [before_widget] =>
* [after_widget] =>
* [before_title] =>
* [after_title] =>
* [widget_id] => archives-2
* [widget_name] => Archives
* )
* [1] => Array
* (
* [number] => 2
* )
* )
*
* Note: No change just yet - the defaults from WP work fine for now.
*
* @param array $params The widget params typically provided by WP
* @return array The params with the updated before/after elements
*/
function change_widget_args( $params )
{
// Intentionally keeping the WP defaults, for now.
return $params;
}
/**
* Retrives the search form. This can be used with the baked-in
* WP search widget or anywhere that calls get_search_form().
*
* @link http://codex.wordpress.org/Function_Reference/get_search_form
* @param type $form The default form markup produced by WP
*/
function change_search_form( $form )
{
return
'
';
}
?>