get( 'TextDomain' ); $active_theme = balanced_blog_get_raw_option( 'stylesheet' ); // return apply_filters( 'balanced_blog_is_preview', ( $active_theme != strtolower( $theme_name ) && ! is_child_theme() ) ); return apply_filters( 'balanced_blog_is_preview', ( $active_theme != strtolower( $theme_name ) ) ); } // Get Raw Options function balanced_blog_get_raw_option( $opt_name ) { $alloptions = wp_cache_get( 'alloptions', 'options' ); $alloptions = maybe_unserialize( $alloptions ); return isset( $alloptions[ $opt_name ] ) ? maybe_unserialize( $alloptions[ $opt_name ] ) : false; } // Random Images function balanced_blog_get_preview_img_src( $i = 0 ) { // prevent infinite loop if ( 6 == $i ) { return ''; } $path = get_template_directory() . '/img/demo/'; // Build or re-build the global dem img array if ( !isset( $GLOBALS[ 'balanced_blog_preview_images' ] ) || empty( $GLOBALS[ 'balanced_blog_preview_images' ] ) ) { $imgs = array( 'image_1.jpg', 'image_2.jpg', 'image_3.jpg', 'image_4.jpg', 'image_5.jpg', 'image_6.jpg' ); $candidates = array(); foreach ( $imgs as $img ) { $candidates[] = $img; } $GLOBALS[ 'balanced_blog_preview_images' ] = $candidates; } $candidates = $GLOBALS[ 'balanced_blog_preview_images' ]; // get a random image name $rand_key = array_rand( $candidates ); $img_name = $candidates[ $rand_key ]; // if file does not exists, reset the global and recursively call it again if ( !file_exists( $path . $img_name ) ) { unset( $GLOBALS[ 'balanced_blog_preview_images' ] ); $i++; return balanced_blog_get_preview_img_src( $i ); } // unset all sizes of the img found and update the global $new_candidates = $candidates; foreach ( $candidates as $_key => $_img ) { if ( substr( $_img, 0, strlen( "{$img_name}" ) ) === "{$img_name}" ) { unset( $new_candidates[ $_key ] ); } } $GLOBALS[ 'balanced_blog_preview_images' ] = $new_candidates; return get_template_directory_uri() . '/img/demo/' . $img_name; } // Featured Images function balanced_blog_preview_thumbnail( $input ) { if ( empty( $input ) && balanced_blog_is_preview() ) { $placeholder = balanced_blog_get_preview_img_src(); return ''; } return $input; } add_filter( 'post_thumbnail_html', 'balanced_blog_preview_thumbnail' ); // Widgets function balanced_blog_preview_right_sidebar() { the_widget( 'balanced_blog_Extended_Recent_Posts', 'title=' . esc_html__( 'Recent posts', 'balanced-blog' ), 'before_title=

&after_title=

&before_widget=
&after_widget=
' ); the_widget( 'WP_Widget_Search', 'title=' . esc_html__( 'Search', 'balanced-blog' ), 'before_title=

&after_title=

&before_widget=' ); the_widget( 'WP_Widget_Archives', 'title=' . esc_html__( 'Archives', 'balanced-blog' ), 'before_title=

&after_title=

&before_widget=
&after_widget=
' ); the_widget( 'WP_Widget_Categories', 'title=' . esc_html__( 'Categories', 'balanced-blog' ), 'before_title=

&after_title=

&before_widget=
&after_widget=
' ); } // Main Menu function balanced_blog_preview_navigation() { $pages = get_pages(); $i = 0; foreach ( $pages as $page ) { if ( ++$i > 6 ) break; $menu_name = esc_html( $page->post_title ); $menu_link = get_page_link( $page->ID ); if ( get_the_ID() == $page->ID ) { $current_class = " current_page_item current-menu-item active"; } else { $current_class = ''; } $menu_class = "page-item-" . $page->ID; echo "
  • " . esc_html( $menu_name ) . "
  • "; } }