display( 'Name' ) );
add_theme_page( $page_name, $page_name, 'manage_options', 'themify', 'themify_base_page' );
}
/**
* Render settings page
*/
function themify_base_page() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to update this site.', 'themify' ) );
}
$theme = wp_get_theme();
$theme_name = is_child_theme() ? $theme->parent()->Name : $theme->display( 'Name' );
?>
' . $description . '
' : '';
}
}
/**
* Echoes page navigation
*
* @param string $before Markup to show before pagination links.
* @param string $after Markup to show after pagination links.
* @param bool $query WordPress query object to use.
* @uses themify_base_get_pagenav
* @since 1.0.0
*/
function themify_base_pagenav( $before = '', $after = '', $query = false ) {
echo themify_base_get_pagenav( $before, $after, $query );
}
if ( ! function_exists( 'themify_base_get_pagenav' ) ) {
/**
* Returns page navigation.
*
* @param string $before Markup to show before pagination links.
* @param string $after Markup to show after pagination links.
* @param bool $query WordPress query object to use.
* @return string
*/
function themify_base_get_pagenav( $before = '', $after = '', $query = false ) {
global $wp_query;
if ( false == $query ) {
$query = $wp_query;
}
$paged = intval( get_query_var( 'paged' ) );
$max_page = $query->max_num_pages;
if ( empty( $paged ) || $paged == 0 ) {
$paged = 1;
}
$pages_to_show = apply_filters( 'themify_filter_pages_to_show', 5 );
$pages_to_show_minus_1 = $pages_to_show - 1;
$half_page_start = floor( $pages_to_show_minus_1 / 2 );
$half_page_end = ceil( $pages_to_show_minus_1 / 2 );
$start_page = $paged - $half_page_start;
if ( $start_page <= 0 ) {
$start_page = 1;
}
$end_page = $paged + $half_page_end;
if ( ( $end_page - $start_page ) != $pages_to_show_minus_1 ) {
$end_page = $start_page + $pages_to_show_minus_1;
}
if ( $end_page > $max_page ) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if ( $start_page <= 0 ) {
$start_page = 1;
}
$out = '';
if ( $max_page > 1 ) {
$out .= $before . '';
if ( $start_page >= 2 && $pages_to_show < $max_page ) {
$first_page_text = "«";
$out .= '
' . $first_page_text . '';
}
if ( $pages_to_show < $max_page ) {
$out .= get_previous_posts_link( '<' );
}
for ( $i = $start_page; $i <= $end_page; $i ++ ) {
if ( $i == $paged ) {
$out .= '
' . $i . ' ';
} else {
$out .= '
' . $i . ' ';
}
}
if ( $pages_to_show < $max_page ) {
$out .= get_next_posts_link( '>' );
}
if ( $end_page < $max_page ) {
$last_page_text = "»";
$out .= '
' . $last_page_text . '';
}
$out .= '
' . $after;
}
return $out;
}
}
/**
* Outputs footer text
* @param string $block The block of text this is.
* @param string $date_fmt Date format for year shown.
* @param bool $echo Whether to echo or return the markup.
* @return string $html The markup and text.
*/
function themify_base_the_footer_text( $block = 'one', $date_fmt = 'Y', $echo = true ) {
if ( 'one' == $block ) {
$text = '© ' . apply_filters( 'themify_base_the_footer_text_' . $block, $text ) . '
';
$html = apply_filters( 'themify_base_the_footer_text', $html, $block );
if ( $echo ) {
echo $html;
}
return $html;
}
/**
* Returns a list of web safe fonts
* @param bool $only_names Whether to return only the array keys or the values as well
* @return mixed|void
* @since 1.0.0
*/
function themify_base_get_web_safe_fonts($only_names = false) {
$web_safe_font_names = array(
'Arial, Helvetica, sans-serif',
'Verdana, Geneva, sans-serif',
'Georgia, \'Times New Roman\', Times, serif',
'\'Times New Roman\', Times, serif',
'Tahoma, Geneva, sans-serif',
'\'Trebuchet MS\', Arial, Helvetica, sans-serif',
'Palatino, \'Palatino Linotype\', \'Book Antiqua\', serif',
'\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif'
);
if( ! $only_names ) {
$web_safe_fonts = array();
foreach( $web_safe_font_names as $font ) {
$web_safe_fonts[str_replace( '\'', '"', $font )] = $font;
}
} else {
$web_safe_fonts = $web_safe_font_names;
}
return apply_filters( 'themify_base_get_web_safe_fonts', $web_safe_fonts );
}
if ( ! function_exists( 'themify_is_touch' ) ) {
/**
* Returns true if it's a phone or tablet
* @param string $check What to check, all, phone or tablet.
* @return bool
*/
function themify_is_touch( $check = 'all' ) {
global $themify_mobile_detect;
switch ( $check ) {
case 'phone':
return $themify_mobile_detect->isMobile() && ! $themify_mobile_detect->isTablet();
break;
case 'tablet':
return $themify_mobile_detect->isTablet();
break;
}
return $themify_mobile_detect->isMobile();
}
}
/**
* Check if the site is using an HTTPS scheme and returns the proper url
* @param string $url The requested to set its scheme.
* @return string
*/
function themify_base_https_esc( $url = '' ) {
if ( is_ssl() ) {
$url = str_replace( 'http://', 'https://', $url );
}
return $url;
}
/**
* Registers footer sidebars.
* @param array $columns Sets of sidebars that can be created.
* @param array $widget_attr General markup for widgets.
* @param string $widgets_key Theme settings key to use.
* @param string $default_set Set of widgets to create.
*/
function themify_base_register_grouped_widgets( $columns = array(), $widget_attr = array(), $widgets_key = 'setting-footer_widgets', $default_set = 'footerwidget-3col' ) {
if ( empty( $columns ) ) {
$columns = array(
'footerwidget-4col' => 4,
'footerwidget-3col' => 3,
'footerwidget-2col' => 2,
'footerwidget-1col' => 1,
'none' => 0
);
}
$option = themify_base_get( $widgets_key, $default_set );
if ( empty( $widget_attr ) ) {
$widget_attr = array(
'sidebar_name' => __( 'Footer Widget', 'themify' ),
'sidebar_id' => 'footer-widget',
'before_widget' => '