git-svn-id: https://192.168.0.254/svn/Proyectos.Afetec_Web/trunk@2 828b2857-b6d9-ce4d-95e2-bbc4707c23a3
823 lines
26 KiB
PHP
823 lines
26 KiB
PHP
<?php
|
|
/**
|
|
* Positive Theme - ThemeForest
|
|
* functions.php which does and tells WordPress to load the theme.
|
|
*
|
|
* @Author: Orkun GURSEL / Ya-Settar, Ya-Gaffar, Ya-Fettâh
|
|
* Email: me@orkungursel.com, support@cloudfw.net
|
|
* Twitter: @orkungursel, @cloudfw
|
|
*
|
|
* @package WordPress
|
|
**/
|
|
|
|
/** !!!There is no any deprecated function */
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
|
/*
|
|
* Check PHP Version is compatible with the theme or not
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
|
echo "Sorry, Theme Positive will only run on PHP version 5 or greater!";
|
|
exit;
|
|
}
|
|
|
|
/*
|
|
* Load Language Files From "languages/" folder
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
load_theme_textdomain( 'cloudfw', TEMPLATEPATH . '/languages' );
|
|
|
|
/* Define Globals */
|
|
|
|
|
|
/*
|
|
* Load & Run CloudFw
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
if (
|
|
file_exists( TEMPLATEPATH . '/cloudfw/inc/fn.php')
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/theme_hooks.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/theme_settings.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/theme_metaboxes.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/theme_widgets.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/theme_shortcodes.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/inc/fn.admin.framework.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/inc/fn.admin.register.php' )
|
|
&& file_exists( TEMPLATEPATH . '/cloudfw/inc/fn.admin.variables.php' )
|
|
){
|
|
|
|
/*--------------- Call .Core Customization Page ----------------*/
|
|
if (file_exists( TEMPLATEPATH . '/customization.core.php'))
|
|
include_once(TEMPLATEPATH . '/customization.core.php');
|
|
/*--------------------------------------------------------*/
|
|
|
|
require(TEMPLATEPATH . '/cloudfw/inc/fn.php');
|
|
|
|
/*--------------- Include The CloudFW ----------------*/
|
|
require(TEMPLATEPATH . '/cloudfw/inc/fn.admin.variables.php');
|
|
require(TEMPLATEPATH . '/cloudfw/inc/fn.admin.framework.php');
|
|
require(TEMPLATEPATH . '/cloudfw/inc/fn.admin.register.php');
|
|
|
|
/*--------------- Call Customization Page ----------------*/
|
|
if (file_exists( TEMPLATEPATH . '/customization.php'))
|
|
include_once(TEMPLATEPATH . '/customization.php');
|
|
/*--------------------------------------------------------*/
|
|
|
|
require(TEMPLATEPATH . '/cloudfw/theme_hooks.php' );
|
|
require(TEMPLATEPATH . '/cloudfw/theme_settings.php' );
|
|
|
|
$_opt = getCO();
|
|
require(TEMPLATEPATH . '/cloudfw/theme_widgets.php' );
|
|
require(TEMPLATEPATH . '/cloudfw/theme_shortcodes.php' );
|
|
|
|
/*--------------- Conditional Including ----------------*/
|
|
if (is_admin()) {
|
|
// Include Following Files for only Admin Area
|
|
|
|
require(TEMPLATEPATH . '/cloudfw/theme_metaboxes.php' );
|
|
include(TEMPLATEPATH . '/cloudfw/inc/fn.menu_walker.php' );
|
|
if (function_exists('cloudfw_megamenu_admin_init'))
|
|
add_action( 'after_setup_theme', 'cloudfw_megamenu_admin_init');
|
|
|
|
}else{
|
|
// ...
|
|
}
|
|
|
|
require(TEMPLATEPATH . '/includes/functions/portfolio_functions.php' );
|
|
|
|
if( defined( 'DOING_AJAX' ) )
|
|
require(TEMPLATEPATH . '/includes/functions/ajax_functions.php' );
|
|
|
|
|
|
// Load Extra Modules
|
|
if (_isOnOff($_opt[PFIX.'_registration']['activate']))
|
|
include(TEMPLATEPATH . '/includes/functions/registration.php' );
|
|
|
|
if (function_exists('icl_register_string'))
|
|
include(TEMPLATEPATH . '/includes/functions/wpml.php' );
|
|
|
|
|
|
}else{
|
|
|
|
echo __('Fatal Error: CloudFw cannot loaded. Some of core files not exists.','cloudfw');
|
|
exit;
|
|
|
|
};
|
|
|
|
|
|
/*
|
|
* Setup Function
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_action( 'after_setup_theme', 'cloudfw_setup_init', 0 );
|
|
|
|
if ( ! function_exists( 'cloudfw_setup_init' ) ) {
|
|
function cloudfw_setup_init() {
|
|
|
|
add_theme_support( 'automatic-feed-links' );
|
|
add_theme_support( 'post-thumbnails', array( 'post', 'portfolio' ) );
|
|
add_image_size('post-thumbnail', 640, 9999);
|
|
register_nav_menus( array('primary' => __( 'Navigation Menu', 'cloudfw' ) ) );
|
|
|
|
if ( ! isset( $content_width ) )
|
|
$content_width = 640;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Load All Environment Units of The Theme
|
|
*
|
|
* Hooks: wp_print_styles, wp_print_scripts, wp_head
|
|
* @since 1.0
|
|
**/
|
|
// Load Css Files
|
|
function cloudfw_load_css(){
|
|
|
|
wp_enqueue_style ('style', TMP_URL.'/style.css');
|
|
wp_enqueue_style ('shortcodes', TMP_URL.'/style.shortcodes.css');
|
|
wp_enqueue_style ('nivo-slider', TMP_URL.'/lib/css/nivo-slider.css');
|
|
wp_enqueue_style ('prettyphoto', TMP_URL.'/lib/css/prettyphoto.css');
|
|
}
|
|
|
|
// Load Javascript Files
|
|
function cloudfw_load_javascripts(){
|
|
|
|
wp_deregister_script('jquery');
|
|
wp_register_script ('jquery', TMP_URL.'/lib/js/jquery.js', NULL, '1.6.2');
|
|
wp_enqueue_script ('jquery');
|
|
if (is_singular())
|
|
wp_enqueue_script ('comment-reply');
|
|
wp_enqueue_script ('webfont', TMP_URL.'/lib/js/webfont.js', array( 'jquery' ));
|
|
wp_enqueue_script ('pack', TMP_URL.'/lib/js/pack.js', array( 'jquery' ));
|
|
wp_enqueue_script ('superfish', TMP_URL.'/lib/js/superfish.js', array( 'jquery' ));
|
|
wp_enqueue_script ('slides', TMP_URL.'/lib/js/slides.min.js', array( 'jquery' ));
|
|
wp_enqueue_script ('tipsy', TMP_URL.'/lib/js/tipsy.js', array( 'jquery' ));
|
|
wp_enqueue_script ('twitter', TMP_URL.'/lib/js/twitter.js', array( 'jquery' ));
|
|
wp_enqueue_script ('custom', TMP_URL.'/lib/js/custom.js', array( 'jquery' ));
|
|
wp_enqueue_script ('prettyphoto', TMP_URL.'/lib/js/prettyphoto.js', array( 'jquery' ));
|
|
wp_enqueue_script ('execute', TMP_URL.'/lib/js/execute.js', array( 'jquery' ));
|
|
|
|
if ($gmap_api_key = get_cOption('apis', 'gmap_api_key'))
|
|
wp_enqueue_script ('gmapapi', 'http://maps.google.com/maps?file=api&v=2&sensor=false&key='.$gmap_api_key, array( 'jquery' ), NULL);
|
|
|
|
}
|
|
|
|
// Add Internet Explorer Patches
|
|
function cloudfw_load_ie_necessaries(){
|
|
|
|
$theme_uri = TMP_URL;
|
|
echo "
|
|
<!--[if IE 9]>
|
|
<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$theme_uri}/lib/css/ie9.css\" />
|
|
<![endif]-->
|
|
|
|
<!--[if lt IE 9]>
|
|
<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$theme_uri}/lib/css/ie.css\" />
|
|
<script src=\"http://html5shiv.googlecode.com/svn/trunk/html5.js\"></script>
|
|
<![endif]-->
|
|
|
|
<!--[if IE 7]>
|
|
<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$theme_uri}/lib/css/ie7.css\" />
|
|
<script src=\"{$theme_uri}/lib/js/ie7Fix.js\"></script>
|
|
<![endif]-->
|
|
";
|
|
|
|
}
|
|
|
|
// Add Javascript Options
|
|
function cloudfw_js_options(){
|
|
|
|
$ajax_url = cloudfw_ajax_url();
|
|
|
|
?><!-- JS Options -->
|
|
<meta name="theme_ajax_url" content="<?php echo $ajax_url; ?>" />
|
|
<meta name="navigation_delay" content="300" />
|
|
<meta name="portfolio_mouse_wheel" content="1" />
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
var ajaxurl = '<?php echo $ajax_url; ?>';
|
|
//]]>
|
|
</script>
|
|
<?php }
|
|
|
|
// Run All Environment Functions
|
|
if (!is_admin()) {
|
|
add_action ('wp_print_styles', 'cloudfw_load_css', 1);
|
|
add_action ('wp_print_scripts', 'cloudfw_load_javascripts', 1);
|
|
add_action ('wp_head', 'cloudfw_js_options', 1);
|
|
add_action ('wp_head', 'cloudfw_load_ie_necessaries', 10);
|
|
}
|
|
|
|
/*
|
|
* Add Homepage Link Into The Navigation Menu
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter( 'wp_nav_menu_items', 'cloudfw_add_homepage_item_to_nav_menu', 10, 2 );
|
|
function cloudfw_add_homepage_item_to_nav_menu($menuItems, $args) {
|
|
$class = '';
|
|
|
|
if('primary' == $args->theme_location) {
|
|
if ( is_front_page() )
|
|
$class .= ' current-menu-item';
|
|
|
|
$homeMenuItem = '<li class="' . $class . '">' .
|
|
$args->before .
|
|
'<a id="the-home" href="'.__home_url().'"><span id="the-home-frame">
|
|
|
|
<span id="the-home-roof" class="the-home-roof-color"></span>
|
|
<span id="the-home-build-1" class="the-home-color the-home-highlight"></span>
|
|
<span id="the-home-build-2" class="the-home-color the-home-highlight"></span>
|
|
<span id="the-home-build-3" class="the-home-color the-home-highlight"></span>
|
|
|
|
</span><span class="navigation-menu-arrow" style="bottom: -2px; left: 25px;"><span class="the-arrow"></span></span></a>' .
|
|
$args->after .
|
|
'</li>';
|
|
|
|
$menuItems = $homeMenuItem . $menuItems;
|
|
}
|
|
|
|
return $menuItems;
|
|
}
|
|
|
|
/*
|
|
* Register Theme Widgets
|
|
*
|
|
* by cloud_widgets_init() on widgets_init hook
|
|
* @since 1.0
|
|
**/
|
|
add_action( 'widgets_init', 'cloud_widgets_init' );
|
|
function cloud_widgets_init() {
|
|
global $_opt, $widget_bars;
|
|
|
|
register_sidebar( array(
|
|
'name' => 'Default Page Sidebar',
|
|
'id' => 'primary-widget-area',
|
|
'description' => 'Default Page Sidebar',
|
|
'before_widget' => '<div class="sector-soft"><div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div></div>',
|
|
'before_title' => '<h3 class="sidebar-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
|
|
|
|
$loop = $_opt[PFIX.'_footer']['widget_number'];
|
|
for ($footer_widget_number = 1; $footer_widget_number <= $loop; $footer_widget_number++) {
|
|
|
|
register_sidebar( array(
|
|
'name' => 'Footer #'.$footer_widget_number,
|
|
'id' => 'footer-widget-area-'.$footer_widget_number,
|
|
'description' => 'Footer Widget Area #'.$footer_widget_number,
|
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="footer-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
|
|
}
|
|
|
|
register_sidebar( array(
|
|
'name' => 'Header Sidebar',
|
|
'id' => 'header-widget-area',
|
|
'description' => '',
|
|
'before_widget' => '<div id="%1$s" class="widget-header %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="header-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
register_sidebar( array(
|
|
'name' => 'Blog Sidebar',
|
|
'id' => 'blog-widget-area',
|
|
'description' => '',
|
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="sidebar-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
register_sidebar( array(
|
|
'name' => 'Search Page Sidebar',
|
|
'id' => 'searchpage-widget-area',
|
|
'description' => 'Search Page Sidebar',
|
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="sidebar-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
register_sidebar( array(
|
|
'name' => 'Archive Pages Sidebar',
|
|
'id' => 'archive-widget-area',
|
|
'description' => 'Archive Pages Sidebar',
|
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="sidebar-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
register_sidebar( array(
|
|
'name' => '404 Error Page Sidebar',
|
|
'id' => '404-widget-area',
|
|
'description' => '404 Error Page Sidebar',
|
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="sidebar-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
|
|
|
|
if ($_opt[PFIX."_custom_sidebars"]):
|
|
|
|
foreach ($_opt[PFIX."_custom_sidebars"] as $bar_id => $bar ){
|
|
|
|
register_sidebar( array(
|
|
'name' => $bar["name"],
|
|
'id' => $bar_id,
|
|
'description' => $bar["desc"],
|
|
'before_widget' => '<div class="sector-soft"><div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div></div>',
|
|
'before_title' => '<h3 class="sidebar-widget-title">',
|
|
'after_title' => '</h3>',
|
|
) );
|
|
|
|
}
|
|
|
|
endif;
|
|
}
|
|
|
|
/*
|
|
* Navigation Menu Callback Function
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
function cloudfw_wp_page_menu_none() {
|
|
echo '
|
|
|
|
<div id="navigation-menu" class="the-page navigation-height">
|
|
|
|
<ul id="navigation-menu-items">
|
|
<li class="navigation-height"><a id="the-home" href="'.home_url().'"><span id="the-home-frame">
|
|
|
|
<span id="the-home-roof" class="the-home-roof-color"></span>
|
|
<span id="the-home-build-1" class="the-home-color the-home-highlight"></span>
|
|
<span id="the-home-build-2" class="the-home-color the-home-highlight"></span>
|
|
<span id="the-home-build-3" class="the-home-color the-home-highlight"></span>
|
|
|
|
</span></a></li>
|
|
|
|
<li class="navigation-height menu-item menu-item-type-post_type depth-0"><a href="'.admin_url('nav-menus.php').'">'.__('Create New Menu','cloudfw').'<span class="navigation-menu-arrow"><span class="the-arrow"></span></span></a></li>
|
|
|
|
</ul><!-- /ul#navigation-menu-items -->
|
|
|
|
</div>
|
|
';
|
|
}
|
|
|
|
/*
|
|
* Exclude Selected & System Pages From Pages List
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('wp_list_pages_excludes', 'cloudfw_excluding_page'); // function cloudfw_excluding_page() -> @cloudfw/inc/fn.php
|
|
|
|
/*
|
|
* Remove WordPress Version Information From Header for Security
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
remove_action('wp_head', 'wp_generator');
|
|
|
|
/*
|
|
* CloudFw Custom Navigation Menu Walker
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
class _walker extends Walker_Nav_Menu
|
|
{
|
|
function start_el(&$output, $item, $depth, $args)
|
|
{
|
|
global $wp_query, $_opt;
|
|
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
|
|
|
|
|
$class_names = $value = '';
|
|
|
|
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
|
$classes[] = 'depth-'.$depth;
|
|
|
|
if ($depth == 0)
|
|
$classes[] = 'navigation-height';
|
|
|
|
|
|
$megaMenu = get_post_meta( $item->ID, PFIX.'_mega_menu_active', true);
|
|
|
|
if (_isOnoff($megaMenu)) {
|
|
|
|
$classes[] = 'megaMenu';
|
|
$columns = get_post_meta( $item->ID, PFIX.'_mega_menu_columns', true);
|
|
|
|
if (!empty($columns))
|
|
$classes[] = "columns-{$columns}";
|
|
|
|
}else{
|
|
|
|
if($depth == 0)
|
|
$classes[] = 'NotmegaMenu';
|
|
|
|
}
|
|
|
|
|
|
if ($depth > 0) {
|
|
|
|
$hide_title = get_post_meta( $item->ID, PFIX.'_mega_menu_hide_title', true);
|
|
$item_image = get_post_meta( $item->ID, PFIX.'_mega_menu_image', true);
|
|
$item_image_kind = get_post_meta( $item->ID, PFIX.'_mega_menu_image_kind', true);
|
|
$item_image_width = get_post_meta( $item->ID, PFIX.'_mega_menu_image_width', true);
|
|
|
|
if (!empty($item_image) && $item_image_kind == 'icon') $classes[] = 'menu-icon';
|
|
if (_isOnoff($hide_title))
|
|
$classes[] = 'menu-hidden-title';
|
|
}
|
|
|
|
|
|
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
|
$class_names = ' class="'. esc_attr( $class_names ) . '"';
|
|
|
|
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
|
|
|
|
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
|
|
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
|
|
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
|
|
$attributes .= ! empty( $item->url ) ? ' href="' . __url(esc_attr( $item->url )) .'"' : '';
|
|
|
|
|
|
$text = get_post_meta( $item->ID, PFIX.'_mega_menu_text', true);
|
|
|
|
if ( ! empty($text) && $depth > 0 )
|
|
$text = "<span class=\"description\">".$text."</span>";
|
|
|
|
|
|
$prepend = '';
|
|
$append = '';
|
|
|
|
|
|
$item_output = $args->before;
|
|
|
|
if (@!empty($item_image) || @!empty($text) || @$hide_title !== 'true') {
|
|
$item_output .= '<a'. $attributes .'>';
|
|
$item_output .= $args->link_before .$prepend;
|
|
if (!empty($item_image)) {
|
|
if ($item_image_kind == 'icon'):
|
|
$item_output .= '<span class="menu-item-image-icon" style="background:url(\''.$item_image.'\') no-repeat scroll 0 50%; padding-left: '.$item_image_width.'px;" >';
|
|
else:
|
|
$item_output .= '<img src="'.$item_image.'" alt="" class="menu-item-image"/>';
|
|
endif;
|
|
}
|
|
if (@!_isOnoff($hide_title) || $depth === 0)
|
|
$item_output .= apply_filters( 'the_title', $item->title, $item->ID );
|
|
if (!empty($item_image) && $item_image_kind == 'icon') $item_output .= '</span>';
|
|
$item_output .= $append;
|
|
$item_output .= $text.$args->link_after;
|
|
if ($depth == 0): $item_output .= '<span class="navigation-menu-arrow"><span class="the-arrow"></span></span>'; endif;
|
|
$item_output .= '</a>';
|
|
|
|
|
|
}
|
|
|
|
$item_output .= $args->after;
|
|
|
|
|
|
// Reset Vars
|
|
$hide_title = $item_image = $item_image_kind = $item_image_width = NULL;
|
|
|
|
|
|
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
|
}
|
|
}
|
|
|
|
/*
|
|
* CloudFw Comments List Function
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
if ( ! function_exists( 'cloudfw_comment_list' ) ) :
|
|
|
|
function cloudfw_comment_list( $comment, $args, $depth ) {
|
|
$GLOBALS['comment'] = $comment;
|
|
switch ( $comment->comment_type ) :
|
|
case '' :
|
|
?>
|
|
|
|
|
|
<div <?php comment_class('comment'); ?> id="comment-<?php comment_ID(); ?>">
|
|
<div class="comment-header">
|
|
|
|
<div class="comment-avatar">
|
|
<?php echo get_avatar( $comment, 35 ); ?>
|
|
</div> <!-- /.comment-avatar -->
|
|
|
|
<div class="comment-meta">
|
|
|
|
<div class="comment-user">
|
|
<?php echo get_comment_author_link(); ?>
|
|
</div> <!-- /.comment-user -->
|
|
|
|
<div class="comment-datetime">
|
|
<span class="timeago" title="<?php echo get_comment_date("Y-m-d").', '. get_comment_time("H:i:s"); ?>"><?php echo get_comment_date().', '. get_comment_time(); ?></span>
|
|
</div> <!-- /.comment-datetime -->
|
|
|
|
</div> <!-- /.comment-meta -->
|
|
|
|
<div class="comment-reply">
|
|
<?php echo get_comment_reply_link( array_merge( $args, array( 'reply_text' => '<span class="sprite no-underline"><span class="reply-text">'.__( 'Reply', 'cloudfw' ).'</span></span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); edit_comment_link( __( '(Edit)', 'cloudfw' ), ' / ' ); ?>
|
|
</div><!-- /.comment-reply -->
|
|
|
|
<div class="cf"></div>
|
|
|
|
</div><!-- /.comment-header -->
|
|
|
|
<div class="comment-text">
|
|
<?php comment_text(); ?>
|
|
|
|
<?php if ( $comment->comment_approved == '0' ) : ?>
|
|
<em style="color:#09C;"><?php _e( 'Your comment is awaiting moderation.', 'cloudfw' ); ?></em>
|
|
<?php endif; ?>
|
|
</div><!-- /.comment-text -->
|
|
|
|
<?php
|
|
break;
|
|
case 'pingback' :
|
|
case 'trackback' :
|
|
?>
|
|
<div class="post pingback">
|
|
|
|
<div class="comment-content">
|
|
|
|
<div style="margin:0 0 20px; "> <?php _e( 'Pingback:', 'cloudfw' ); ?> <?php comment_author_link(); ?></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<?php
|
|
break;
|
|
endswitch;
|
|
}
|
|
endif;
|
|
|
|
/*
|
|
* Default Comment Fields
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter( 'comment_form_default_fields', 'cloudfw_comment_form_default_fields' );
|
|
function cloudfw_comment_form_default_fields() {
|
|
|
|
$fields = array(
|
|
'author' => '<div id="hidden-comment-form-parts"><p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
|
|
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
|
|
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
|
|
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
|
|
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
|
|
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p></div>',
|
|
);
|
|
|
|
return $fields;
|
|
}
|
|
|
|
/*
|
|
* Edit Global WP Query for Search Pages
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('pre_get_posts', 'cloudfw_search_only_post');
|
|
function cloudfw_search_only_post( $query ) {
|
|
if($query->is_search)
|
|
$query->set('post_type', 'post');
|
|
return $query;
|
|
}
|
|
|
|
/*
|
|
* Exclude Selected Categories From Categories List
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('pre_get_posts', 'cloudfw_exclude_blog_category');
|
|
function cloudfw_exclude_blog_category($query) {
|
|
$page_for_posts = get_option("page_for_posts");
|
|
|
|
if ( ! $page_for_posts )
|
|
return $query;
|
|
|
|
if ( isset($query ->queried_object_id) ):
|
|
if ( $query ->queried_object_id == $page_for_posts ) {
|
|
|
|
global $_opt;
|
|
$exclude = $_opt[PFIX."_excluded_blog_categories"];
|
|
|
|
foreach ((array)$exclude as $ec) {
|
|
$result .= ' -' . $ec;
|
|
}
|
|
$query->set('cat', $result);
|
|
}
|
|
endif;
|
|
return $query;
|
|
}
|
|
|
|
|
|
/*
|
|
* Hide Selected Categories From Categories List
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('the_category','the_category_filter', 10, 2);
|
|
function the_category_filter($thelist, $separator=' ') {
|
|
if(!defined('WP_ADMIN')) {
|
|
global $_opt;
|
|
$exclude = $_opt[PFIX."_hidden_blog_categories"];
|
|
|
|
$exclude2 = array();
|
|
foreach($exclude as $c) {
|
|
$exclude2[] = get_cat_name($c);
|
|
}
|
|
|
|
$cats = explode($separator,$thelist);
|
|
$newlist = array();
|
|
foreach($cats as $cat) {
|
|
$catname = trim(strip_tags($cat));
|
|
if(!in_array($catname,$exclude2))
|
|
$newlist[] = $cat;
|
|
}
|
|
return implode($separator,$newlist);
|
|
} else {
|
|
return $thelist;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Hide Selected Categories From Categories List
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('widget_categories_args','list_cats_args_filter');
|
|
function list_cats_args_filter( $cat_args ) {
|
|
global $_opt;
|
|
if (is_array($_opt[PFIX."_hidden_blog_categories"])) {
|
|
$cat_args['exclude'] = implode(",", $_opt[PFIX."_hidden_blog_categories"]);
|
|
}
|
|
return $cat_args;
|
|
}
|
|
|
|
/*
|
|
* Add Shortcode Support to Wdiget Texts
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('widget_text', 'do_shortcode');
|
|
|
|
/*
|
|
* Add Extra Profile Information
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_action( 'edit_user_profile', 'cloudfw_extra_profile_fields' );
|
|
function cloudfw_extra_profile_fields( $user ) { ?>
|
|
|
|
<h3><?php _e('Extra Profile Information','cloudfw'); ?></h3>
|
|
<table class="form-table">
|
|
<tr>
|
|
<th><label for="twitter"><?php _e('Facebook Page URL','cloudfw'); ?></label></th>
|
|
<td>
|
|
<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
<span class="description"><?php _e('Please enter your Facebook Page URL.','cloudfw'); ?></span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="twitter"><?php _e('Twitter Page URL','cloudfw'); ?></label></th>
|
|
<td>
|
|
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
|
|
<span class="description"><?php _e('Please enter only your Twitter Username.','cloudfw'); ?></span>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<?php }
|
|
|
|
/*
|
|
* Handler for Extra Profile Information
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_action( 'personal_options_update', 'cloudfw_save_extra_profile_fields' );
|
|
add_action( 'edit_user_profile_update', 'cloudfw_save_extra_profile_fields' );
|
|
function cloudfw_save_extra_profile_fields( $user_id ) {
|
|
|
|
if ( !current_user_can( 'edit_user', $user_id ) )
|
|
return false;
|
|
|
|
update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
|
|
update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
|
|
}
|
|
|
|
|
|
/*
|
|
* Fix Video Embedding
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
function cloudfw_fixEmbed($oembvideo, $url, $attr) {
|
|
$width = 0;
|
|
$height = 0;
|
|
$newheight = 0;
|
|
$attrstart = strpos($oembvideo,'width="');
|
|
|
|
if($attrstart !== false) {
|
|
$attrstart += 7;
|
|
$width = substr($oembvideo, $attrstart, strpos($oembvideo,'"',$attrstart+1)-$attrstart);
|
|
$attrstart = strpos($oembvideo,'height="');
|
|
|
|
if(($attrstart !== false) && $width > 0) {
|
|
$attrstart += 8;
|
|
$height = substr($oembvideo, $attrstart, strpos($oembvideo,'"',$attrstart+1)-$attrstart);
|
|
$newheight = round($height*$attr['width']/$width);
|
|
|
|
if ($attr['force'] == 1) {
|
|
$oembvideo = str_replace('height="'.$height,'height="'.$attr['height'], str_replace('width="'.$width,'width="'.$attr['width'], $oembvideo));
|
|
}else{
|
|
$oembvideo = str_replace('height="'.$height,'height="'.$newheight, str_replace('width="'.$width,'width="'.$attr['width'], $oembvideo));
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
return $oembvideo;
|
|
}
|
|
add_filter('embed_oembed_html', 'cloudfw_fixEmbed', 10, 3);
|
|
|
|
|
|
/*
|
|
* Add CloudFw Menu into The Admin Bar
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_action( 'admin_bar_menu', 'my_wp_admin_bar_theme_options', 999 );
|
|
function my_wp_admin_bar_theme_options() {
|
|
|
|
global $wp_admin_bar, $theme_setting_slug, $slider_slug;
|
|
|
|
$last_version = is_need_update();
|
|
$who_can_see = get_cOption('framework', 'who_can_see');
|
|
$menu_title = get_cOption('framework', 'title');
|
|
|
|
if ( $who_can_see == get_current_user_id() || $who_can_see == 0 || !isset($who_can_see ) ) {
|
|
|
|
$wp_admin_bar -> add_menu( array(
|
|
'id' => 'cloudfw',
|
|
'title' => $menu_title._isso($last_version,' <span class="update-count" id="ab-updates">1</span>'),
|
|
'href' => admin_url('admin.php?page='.$theme_setting_slug)
|
|
) );
|
|
|
|
}
|
|
if ( current_user_can('administrator') ) {
|
|
|
|
$wp_admin_bar -> add_menu( array(
|
|
'id' => 'cloudfw_sliders',
|
|
'title' => __('Slider Manager','cloudfw'),
|
|
'href' => admin_url('admin.php?page='.$slider_slug)
|
|
) );
|
|
|
|
}
|
|
|
|
/*if ($nav_pages) {
|
|
foreach ($nav_pages as $nav_page ) {
|
|
|
|
$wp_admin_bar -> add_menu( array(
|
|
'parent' => 'cloudfw',
|
|
'title' => ucwords($nav_page["page_title"]),
|
|
'href' => admin_url("admin.php?page=".$theme_setting_slug."&tab=".$nav_page["page_slug"]."")
|
|
) );
|
|
|
|
};
|
|
}*/
|
|
|
|
}
|
|
|
|
/*
|
|
* Add Clear Fixer After Post and Page Contents
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
add_filter('the_content','insert_clearfix_after_contents',100);
|
|
function insert_clearfix_after_contents( $content ) {
|
|
return $content . '<div class="cf"></div>';
|
|
}
|
|
|
|
/*
|
|
* Fix Ajax Results
|
|
*
|
|
* @since 1.0
|
|
**/
|
|
if ( defined ( 'DOING_AJAX' ) && DOING_AJAX )
|
|
add_filter( 'doing_it_wrong_trigger_error', '__return_false', 10 );
|