__( 'Top Menu', 'cactus' ),
'top-left' => __( 'Top Left Menu (Split Navigation Bar)', 'cactus' ),
) );
/*
* 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',
) );
// Add theme support for Custom Logo.
add_theme_support( 'custom-logo', array(
'height' => 100,
'flex-width' => true,
'flex-height' => true,
) );
// Setup the WordPress core custom header feature.
add_theme_support( 'custom-header', array(
'default-image' => '',
'random-default' => false,
'width' => '1920',
'height' => '70',
'flex-height' => true,
'flex-width' => true,
'default-text-color' => '#333333',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => ''
));
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', array(
'default-color' => 'ffffff',
'default-image' => '',
) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
// Woocommerce Support
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 Works Image size
add_image_size( 'cactus-works', 480, 360, true );
/*
* 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' ) );
}
add_action( 'after_setup_theme', 'cactus_setup' );
/**
* After switch theme
*/
function cactus_after_switch_theme(){
delete_option('cactus_welcome_notice');
}
add_action('after_switch_theme', 'cactus_after_switch_theme');
/**
* Enqueue scripts and styles.
*/
function cactus_scripts() {
global $cactus_options, $cactus_sections;
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
$headings_font_family = esc_attr(cactus_option( 'headings_font_family'));
$body_font_family = esc_attr(cactus_option( 'body_font_family'));
$page_preloader = absint(cactus_option( 'page_preloader'));
$fonts[] = $headings_font_family;
$fonts[] = $body_font_family;
wp_enqueue_style( 'cactus-google-fonts', customizer_library_get_google_font_uri($fonts), false, '', false );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() .'/assets/plugins/bootstrap/css/bootstrap.css', false, '', false );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() .'/assets/plugins/font-awesome/css/font-awesome.min.css', false, '', false );
wp_enqueue_style( 'owl-carousel', get_template_directory_uri() .'/assets/plugins/owl-carousel/css/owl.carousel.css', false, '', false );
wp_enqueue_style( 'prettyphoto', get_template_directory_uri() .'/assets/plugins/prettyphoto/css/prettyPhoto.min.css', false, '', false );
// Theme stylesheet.
wp_enqueue_style( 'cactus-style', get_stylesheet_uri() );
if(is_page_template( 'template-sections.php' )){
wp_enqueue_style( 'cactus-frontpage', get_template_directory_uri() .'/assets/css/frontpage.css' );
wp_enqueue_style( 'animate', get_template_directory_uri() .'/assets/plugins/animate.css' );
}
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/plugins/bootstrap/js/bootstrap.min.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'respond', get_template_directory_uri() . '/assets/plugins/respond.min.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/assets/plugins/owl-carousel/js/owl.carousel.min.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'jquery-waypoints', get_template_directory_uri() . '/assets/plugins/waypoints/jquery.waypoints.min.js' , array( 'jquery' ), null, true);
if(cactus_option('section_hide_counter')!='1'&&cactus_option('section_hide_counter')!='on')
wp_enqueue_script( 'jquery-counterup', get_template_directory_uri() . '/assets/plugins/counter-up/jquery.counterup.js' , array( 'jquery' ), null, true);
$mixitup = 0;
if(cactus_option('section_hide_works')!='1' || is_customize_preview() ){
$mixitup = 1;
wp_enqueue_script( 'mixitup', get_template_directory_uri() . '/assets/plugins/mixitup/mixitup.min.js' , array( 'jquery' ), null, true);
}
$isotope = 0;
if( (cactus_option('blog_list_style')=='3'&& (is_archive() || is_home())) || is_customize_preview() ){
$isotope = 1;
wp_enqueue_script( 'imagesloaded');
wp_enqueue_script( 'isotope', get_template_directory_uri() . '/assets/plugins/isotope/isotope.pkgd.js' , array( 'jquery' ), null, true );
}
$video_background = 0;
$banner_video = '';
if((cactus_option('section_hide_banner')!='1' && cactus_option('type_banner')=='2' )|| is_customize_preview() ){
if(cactus_option('type_banner')=='2')
$video_background = 1;
$banner_video = cactus_option('video_banner');
wp_enqueue_style( 'jquery-mb-vimeo_player', get_template_directory_uri() .'/assets/plugins/jquery.mb.vimeo_player/css/jquery.mb.vimeo_player.min.css', false, '', false );
wp_enqueue_style( 'jquery-mb-ytplayer', get_template_directory_uri() .'/assets/plugins/jquery.mb.YTPlayer/css/jquery.mb.YTPlayer.min.css', false, '', false );
wp_enqueue_script( 'jquery-mb-vimeo_player', get_template_directory_uri() . '/assets/plugins/jquery.mb.vimeo_player/jquery.mb.vimeo_player.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'jquery-mb-ytplayer', get_template_directory_uri() . '/assets/plugins/jquery.mb.YTPlayer/jquery.mb.YTPlayer.js' , array( 'jquery' ), null, true);
}
wp_enqueue_script( 'jquery-parallax', get_template_directory_uri() . '/assets/plugins/parallax/jquery.parallax-1.1.3.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'jquery-prettyphoto', get_template_directory_uri() . '/assets/plugins/prettyphoto/js/jquery.prettyPhoto.min.js' , array( 'jquery' ), null, true);
if( $page_preloader == '1' || is_customize_preview() )
wp_enqueue_script( 'loadingoverlay', get_template_directory_uri() . '/assets/plugins/jquery-loading-overlay/loadingoverlay.js' , array( 'jquery' ), null, true);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if(cactus_option('slider_autoplay_banner')=='1')
$slider_autoplay = true;
else
$slider_autoplay = false;
$autoplaytimeout = cactus_option('autoplaytimeout_banner');
$autoplaytimeout = absint($autoplaytimeout);
$preloader_background = esc_attr(cactus_option('preloader_background'));
$preloader_opacity = esc_attr(cactus_option('preloader_opacity'));
$preloader_image = esc_attr(cactus_option('preloader_image'));
if (is_numeric($preloader_image)) {
$image_attributes = wp_get_attachment_image_src($preloader_image, 'full');
$preloader_image = $image_attributes[0];
}
$preloader_bg = '';
if($preloader_background!=''){
$rgb = cactus_hex2rgb( $preloader_background );
$preloader_bg = "rgba(".$rgb[0].",".$rgb[1].",".$rgb[2].",".$preloader_opacity.")";
}
wp_enqueue_script( 'cactus-main', get_template_directory_uri() . '/assets/js/cactus.js' , array( 'jquery' ), null, true);
wp_localize_script( 'cactus-main', 'cactus_params', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'themeurl' => get_template_directory_uri(),
'mixitup' => $mixitup,
'isotope' => $isotope,
'video_background' => $video_background,
'banner_video' => $banner_video,
'slider_autoplay' => $slider_autoplay,
'autoplaytimeout' => $autoplaytimeout,
'page_preloader' => $page_preloader,
'preloader_background' => $preloader_bg,
'preloader_image' => $preloader_image,
) );
$custom_css = '';
$header_text_color = get_header_textcolor();
if ( 'blank' != $header_text_color ) :
$custom_css .= ".site-name,
.site-tagline {
color: ".esc_attr( $header_text_color )." !important;
}.site-tagline {
display: none;
}\r\n";
else:
$custom_css .= ".site-name,
.site-tagline {
display: none;
}\r\n";
endif;
// Font family
$custom_css .= "h1,h2,h3,h4,h5,h6{font-family:".$headings_font_family.";}";
$custom_css .= "html, div, span, applet, object, iframe, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {font-family:".$body_font_family.";}";
// Font size
$body_font_size = absint(cactus_option('body_font_size'));
$custom_css .= "html, body, div{font-size:".$body_font_size."px;}";
for($i=1;$i<=6;$i++){
$heading_font_size = absint(cactus_option('h'.$i.'_font_size'));
$custom_css .= "h".$i."{font-size:".$heading_font_size."px;}";
}
// Section Font size
$section_title_font_size = absint(cactus_option('section_title_font_size'));
$custom_css .= ".cactus-section .cactus-section-title{font-size:".$section_title_font_size."px;}";
$section_subtitle_font_size = absint(cactus_option('section_subtitle_font_size'));
$custom_css .= ".cactus-section .cactus-section-desc{font-size:".$section_subtitle_font_size."px;}";
$section_item_title_font_size = absint(cactus_option('section_item_title_font_size'));
$custom_css .= ".cactus-section h4{font-size:".$section_item_title_font_size."px;}";
$section_content_font_size = absint(cactus_option('section_content_font_size'));
$custom_css .= ".cactus-section, .cactus-section p, .cactus-section div{font-size:".$section_content_font_size."px;}";
$sticky_header_background_color = cactus_option('sticky_header_background_color');
$sticky_header_background_opacity = cactus_option('sticky_header_background_opacity');
if( $sticky_header_background_color!='' ){
$rgb = customizer_library_hex_to_rgb($sticky_header_background_color);
$custom_css .= "header .cactus-fixed-header-wrap,header .cactus-fixed-header-wrap .cactus-header{background-color:rgba(".$rgb['r'].",".$rgb['g'].",".$rgb['b'].",".$sticky_header_background_opacity.");}";
}
foreach($cactus_sections as $key=>$name ){
$background_color = cactus_option('background_color_'.$key);
$background_image = cactus_option('background_image_'.$key);
$section_padding = cactus_option('section_padding_'.$key);
if (is_numeric($background_image)) {
$image_attributes = wp_get_attachment_image_src($background_image, 'full');
$background_image = $image_attributes[0];
}
if($background_color!=''||$background_image!='')
$custom_css .= ".cactus-section-".$key." {
background-color:".esc_attr( $background_color ).";
background-image:url(".esc_attr( $background_image ).");
}\r\n";
if($section_padding!='')
$custom_css .= ".cactus-section-".$key." .cactus-section-content {
padding:".$section_padding.";
}\r\n";
}
$video_poster_banner = cactus_option('video_poster_banner');
if($video_poster_banner)
$custom_css .= ".banner_video_background{
background-image:url(".esc_attr( $video_poster_banner ).");
}\r\n";
$custom_css = apply_filters( 'cactus_additional_css', $custom_css );
wp_add_inline_style( 'cactus-style', wp_filter_nohtml_kses($custom_css) );
}
add_action( 'wp_enqueue_scripts', 'cactus_scripts' );
function cactus_admin_scripts(){
global $pagenow;
wp_enqueue_script( 'cactus-admin', get_template_directory_uri().'/assets/js/admin.js', array( 'jquery' ), '', true );
if( $pagenow == "themes.php" && isset($_GET['page']) && $_GET['page'] == "cactus-welcome" ):
wp_enqueue_style( 'cactus-admin', get_template_directory_uri() . '/assets/css/admin.css', '', '', false );
endif;
}
add_action( 'admin_enqueue_scripts', 'cactus_admin_scripts' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function cactus_customize_controls_enqueue(){
wp_enqueue_style( 'cactus_library_customizer', get_template_directory_uri() . '/assets/css/customizer.css', '', '1.0.0', false );
wp_enqueue_script( 'cactus_library_customizer_controls', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview', 'jquery-ui-sortable', 'jquery-ui-autocomplete' ), '1.0.0', true );
wp_enqueue_style( 'jquery-mb-vimeo_player', get_template_directory_uri() .'/assets/plugins/jquery.mb.vimeo_player/css/jquery.mb.vimeo_player.min.css', false, '', false );
wp_enqueue_style( 'jquery-mb-ytplayer', get_template_directory_uri() .'/assets/plugins/jquery.mb.YTPlayer/css/jquery.mb.YTPlayer.min.css', false, '', false );
wp_enqueue_script( 'jquery-mb-vimeo_player', get_template_directory_uri() . '/assets/plugins/jquery.mb.vimeo_player/jquery.mb.vimeo_player.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'jquery-mb-ytplayer', get_template_directory_uri() . '/assets/plugins/jquery.mb.YTPlayer/jquery.mb.YTPlayer.js' , array( 'jquery' ), null, true);
$loading = __('Updating','cactus');
$complete = __('Complete','cactus');
$error = __('Error','cactus');
$import_options = __('Restore Defaults','cactus');
$confirm = esc_js( __( 'Click OK to reset. Any Cactus options will be restored!', 'cactus' ) );
$confirm_import = esc_js( __( 'Click OK to import. Any Cactus options will be overwritten!', 'cactus' ) );
wp_localize_script( 'cactus_library_customizer_controls', 'cactus_customize_params', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'themeurl' => get_template_directory_uri(),
'loading' => $loading,
'complete' => $complete,
'error' => $error,
'import_options' =>$import_options,
'confirm' =>$confirm,
'confirm_import' =>$confirm_import,
) );
}
add_action( 'customize_controls_init', 'cactus_customize_controls_enqueue' );
function cactus_customize_preview_enqueue(){
wp_enqueue_script( 'cactus_library_customizer_preview', get_template_directory_uri() . '/assets/js/customizer-preview.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'customize_preview_init', 'cactus_customize_preview_enqueue' );
/*
* restore default
*/
function cactus_otpions_restore(){
add_option(CACTUS_TEXTDOMAIN.'_backup_'.time(),get_option(CACTUS_TEXTDOMAIN));
delete_option(CACTUS_TEXTDOMAIN);
echo 'done';
exit(0);
}
add_action( 'wp_ajax_cactus_otpions_restore', 'cactus_otpions_restore' );
add_action( 'wp_ajax_nopriv_cactus_otpions_restore', 'cactus_otpions_restore' );
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function cactus_posted_on() {
// Get the author name; wrap it in a link.
$byline = sprintf(
/* translators: %s: post author */
__( 'by %s', 'cactus' ),
' ' . get_the_author() . ' '
);
// Finally, let's write all of this to the page.
echo '' . cactus_time_link() . ' | ' . $byline . '';
}
/**
* Gets a nicely formatted string for the published date.
*/
function cactus_time_link() {
$time_string = '%2$s ';
$time_string = sprintf( $time_string,
get_the_date( DATE_W3C ),
get_the_date(),
get_the_modified_date( DATE_W3C ),
get_the_modified_date()
);
// Wrap the time string in a link, and preface it with 'Posted on'.
return sprintf(
/* translators: %s: post date */
__( 'Posted on %s ', 'cactus' ),
'' . $time_string . ' '
);
}
/**
* Returns an accessibility-friendly link to edit a post or page.
*/
function cactus_edit_link() {
$link = edit_post_link(
sprintf(
/* translators: %s: Name of current post */
__( 'Edit "%s" ', 'cactus' ),
get_the_title()
),
'',
' '
);
return $link;
}
/**
* Register widget area.
*
*/
function cactus_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'cactus' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'cactus' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Page Sidebar', 'cactus' ),
'id' => 'sidebar-page',
'description' => __( 'Add widgets here to appear in your pages sidebar.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'cactus' ),
'id' => 'sidebar-blog',
'description' => __( 'Add widgets here to appear in your posts sidebar.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Archives', 'cactus' ),
'id' => 'sidebar-archives',
'description' => __( 'Add widgets here to appear in your posts list sidebar.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 1', 'cactus' ),
'id' => 'footer-1',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 2', 'cactus' ),
'id' => 'footer-2',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 3', 'cactus' ),
'id' => 'footer-3',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 4', 'cactus' ),
'id' => 'footer-4',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'cactus_widgets_init' );
/**
* Custom comments list
*/
function cactus_comment($comment, $args, $depth) {
?>
id="comment-">
comment_approved == '0') : ?>
';
$after = '';
if ( !is_home() && !is_front_page() || is_paged() ) {
echo '';
global $post;
$homeLink = esc_url(home_url());
echo '
' . __( 'Home' , 'cactus' ) . ' ' . $delimiter . ' ';
if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0){
$cat_code = get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' ');
echo $cat_code = str_replace ('
' . get_the_time('Y') . ' ' . $delimiter . ' ';
echo '
' . get_the_time('F') . ' ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
echo '
' . get_the_time('Y') . ' ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '
' . $post_type->labels->singular_name . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
$cat_code = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo $cat_code = str_replace ('
labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = isset($cat[0])?$cat[0]:'';
echo ' ' . $parent->post_title . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif ( is_page() && !$post->post_parent ) {
echo $before . get_the_title() . $after;
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '
' . get_the_title($page->ID) . ' ';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif ( is_search() ) {
echo $before ;
printf( __( 'Search Results for: %s', 'cactus' ), get_search_query() );
echo $after;
} elseif ( is_tag() ) {
echo $before ;
printf( __( 'Tag Archives: %s', 'cactus' ), single_tag_title( '', false ) );
echo $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before ;
printf( __( 'Author Archives: %s', 'cactus' ), $userdata->display_name );
echo $after;
} elseif ( is_404() ) {
echo $before;
_e( 'Not Found', 'cactus' );
echo $after;
}
if ( get_query_var('paged') ) {
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() )
echo sprintf( __( '( Page %s )', 'cactus' ), get_query_var('paged') );
}
echo '
';
}
}
/**
* Get option
*/
function cactus_option($name){
global $cactus_options,$cactus_default_sections;
if( isset($cactus_options[$name]) )
return $cactus_options[$name];
elseif(isset($cactus_default_sections[$name]))
return $cactus_default_sections[$name];
else
return '';
}
function cactus_option_saved($name){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options[$name]) )
return $cactus_options[$name];
else
return '';
}
/**
* Do sections
*/
function cactus_do_sections(){
global $cactus_sections, $cactus_section_key, $cactus_animation;
$cactus_new_sections = array();
$homepage_animation = cactus_option('homepage_animation');
if($homepage_animation == '0' || $homepage_animation == '' )
$cactus_animation = '';
else
$cactus_animation = 'cactus-animation';
$section_order = cactus_option('section_order');
if($section_order !=''){
$my_sections = @json_decode($section_order,true);
if(is_array($my_sections)){
foreach($my_sections as $key){
if(isset($cactus_sections[$key]))
$cactus_new_sections[$key] = $cactus_sections[$key];
}
}
}
if(!empty($cactus_new_sections))
$cactus_sections = $cactus_new_sections;
if( $cactus_sections ){
foreach( $cactus_sections as $key=>$value){
$section_id = cactus_option('section_id_'.$key);
$section_hide = cactus_option('section_hide_'.$key);
$font_color = cactus_option('font_color_'.$key);
$background_parallax = cactus_option('background_parallax_'.$key);
$css_class = 'cactus-section cactus-section-'.$key;
if( $background_parallax == '1' ){
$css_class .= ' cactus-parallax';
}
if( $font_color == '1' ){
$css_class .= ' cactus-text-light';
}
$cactus_section_key = $key;
if( $section_hide != '1' || is_customize_preview() ):
if (is_customize_preview() && $section_hide == '1')
$css_class .= ' hide';
echo '';
do_action('cactus_before_section_'.$key);
get_template_part('sections/template',$key);
do_action('cactus_after_section_'.$key);
echo '
';
endif;
}
}
}
add_action('cactus_sections','cactus_do_sections');
/**
* Get sidebar
*/
function cactus_get_sidebar($layout,$type){
if($layout=='' || $layout == 'none' || $layout == 'no' )
return '';
?>
';
}
$fb_output .= ''.__('How to create top menu','cactus').'';
$fb_output .= ' ';
if ( $container )
$fb_output .= '' . $container . '>';
$allowed_html = array(
'a' => array( 'href' => array(), ),
'div' => array( 'id' => array(), 'class' => array(), ),
'ul' => array( 'class' => array() ),
'li' => array(),
'span' => array(),
);
echo wp_kses( $fb_output, $allowed_html );
// }
}
/**
* Split header left menu
*/
function cactus_header_left_menu( $args ) {
extract( $args );
$fb_output = null;
if ( $container ) {
$fb_output = '<' . $container;
if ( $container_id )
$fb_output .= ' id="' . $container_id . '"';
if ( $container_class )
$fb_output .= ' class="' . $container_class . '"';
$fb_output .= '>';
}
$fb_output .= '' . esc_attr( $item['title'] ) .' ';
endforeach;
endif;
$fb_output .= ' ';
if ( $container )
$fb_output .= '' . $container . '>';
$allowed_html = array(
'a' => array( 'href' => array(), ),
'div' => array( 'id' => array(), 'class' => array(), ),
'ul' => array( 'class' => array() ),
'li' => array(),
'span' => array(),
);
echo wp_kses( $fb_output, $allowed_html );
}
/**
* Function to change sections order
*/
function cactus_reorder_section($cactus_sections) {
$cactus_new_sections = array();
$section_order = cactus_option_saved('section_order');
if($section_order !=''){
$my_sections = @json_decode($section_order,true);
if(is_array($my_sections)){
foreach($my_sections as $key){
if(isset($cactus_sections[$key]))
$cactus_new_sections[$key] = $cactus_sections[$key];
}
}
}
if(!empty($cactus_new_sections))
$cactus_sections = array_merge($cactus_new_sections,$cactus_sections);
return $cactus_sections;
}
add_filter( 'cactus_get_sections','cactus_reorder_section' );
/**
* Selective Refresh
*/
function cactus_register_partials( WP_Customize_Manager $wp_customize ) {
global $cactus_customizer_options;
$sections = cactus_get_sections();
// Abort if selective refresh is not available.
if ( ! isset( $wp_customize->selective_refresh ) ) {
return;
}
// Bail early if we don't have any options.
if ( empty( $cactus_customizer_options ) ) {
return;
}
// Loops through each of the options
/* foreach ( $cactus_customizer_options as $option ) {
if(isset($option['type']) && ($option['type'] == 'text' || $option['type'] == 'textarea' || $option['type'] == 'editor' || $option['type'] == 'image' || $option['type'] == 'repeater' ) ){
$wp_customize->selective_refresh->add_partial( $option['id'].'_selective', array(
'selector' => '.'.$option['id'].'_selective',
'settings' => array( CACTUS_TEXTDOMAIN.'['.$option['id'].']' ),
));
}
}*/
foreach($sections as $key => $value){
$wp_customize->selective_refresh->add_partial( 'section_title_'.$key.'_selective', array(
'selector' => '.section_title_'.$key.'_selective',
'settings' => array( 'cactus[section_title_'.$key.']' ),
'render_callback' => 'cactus_section_title_'.$key.'',
) );
$wp_customize->selective_refresh->add_partial( 'section_subtitle_'.$key.'_selective', array(
'selector' => '.section_subtitle_'.$key.'_selective',
'settings' => array( 'cactus[section_subtitle_'.$key.']' ),
'render_callback' => 'cactus_section_subtitle_'.$key.'',
) );
}
$wp_customize->selective_refresh->add_partial( 'video_title_banner_selective', array(
'selector' => '.video_title_banner_selective',
'settings' => array( 'cactus[video_title_banner]' ),
'render_callback' => 'cactus_video_title_banner',
) );
$wp_customize->selective_refresh->add_partial( 'video_subtitle_banner_selective', array(
'selector' => '.video_subtitle_banner_selective',
'settings' => array( 'cactus[video_subtitle_banner]' ),
'render_callback' => 'cactus_video_subtitle_banner',
) );
$wp_customize->selective_refresh->add_partial( 'button_text_banner_selective', array(
'selector' => '.button_text_banner_selective',
'settings' => array( 'cactus[button_text_banner]' ),
'render_callback' => 'cactus_button_text_banner',
) );
/*$wp_customize->selective_refresh->add_partial( 'button_link_banner_selective', array(
'selector' => '.button_link_banner_selective',
'settings' => array( 'cactus[button_link_banner]' ),
//'render_callback' => 'cactus_button_link_banner',
) );*/
$wp_customize->selective_refresh->add_partial( 'text_promo_selective', array(
'selector' => '.text_promo_selective',
'settings' => array( 'cactus[text_promo]' ),
'render_callback' => 'cactus_text_promo',
) );
$wp_customize->selective_refresh->add_partial( 'button_text_promo_selective', array(
'selector' => '.button_text_promo_selective',
'settings' => array( 'cactus[button_text_promo]' ),
'render_callback' => 'cactus_button_text_promo',
) );
$wp_customize->selective_refresh->add_partial( 'address_contact_selective', array(
'selector' => '.address_contact_selective',
'settings' => array( 'cactus[address_contact]' ),
'render_callback' => 'cactus_address_contact',
) );
$wp_customize->selective_refresh->add_partial( 'email_contact_selective', array(
'selector' => '.email_contact_selective',
'settings' => array( 'cactus[email_contact]' ),
'render_callback' => 'cactus_email_contact',
) );
$wp_customize->selective_refresh->add_partial( 'tel_contact_selective', array(
'selector' => '.tel_contact_selective',
'settings' => array( 'cactus[tel_contact]' ),
'render_callback' => 'cactus_tel_contact',
) );
$wp_customize->selective_refresh->add_partial( 'button_text_news_selective', array(
'selector' => '.button_text_news_selective',
'settings' => array( 'cactus[button_text_news]' ),
'render_callback' => 'cactus_button_text_news',
) );
$wp_customize->selective_refresh->add_partial( 'button_text_call_to_action_selective', array(
'selector' => '.button_text_call_to_action_selective',
'settings' => array( 'cactus[button_text_call_to_action]' ),
'render_callback' => 'cactus_button_text_call_to_action',
) );
$wp_customize->selective_refresh->add_partial( 'section_shop_selective', array(
'selector' => '.section_shop_selective',
'settings' => array( 'cactus[items_shop]', 'cactus[categories_shop]', 'cactus[orderby_shop]', 'cactus[order_shop]', 'cactus[shortcode_shop]' ),
'render_callback' => 'cactus_section_shop_selective',
) );
$wp_customize->selective_refresh->add_partial( 'copyright_selective', array(
'selector' => '.copyright_selective',
'settings' => array( 'cactus[copyright]' ),
'render_callback' => 'cactus_copyright',
) );
$wp_customize->selective_refresh->add_partial( 'footer_logo_selective', array(
'selector' => '.footer_logo_selective',
'settings' => array( 'cactus[footer_logo]' ),
'render_callback' => '',
) );
/*$wp_customize->selective_refresh->add_partial( 'image_contact_selective', array(
'selector' => '.image_contact_selective',
'settings' => array( 'cactus[image_contact]' ),
) );*/
$wp_customize->selective_refresh->add_partial( 'header_site_title', array(
'selector' => '.site-name',
'settings' => array( 'blogname' ),
'render_callback' => 'cactus_header_site_title',
) );
$wp_customize->selective_refresh->add_partial( 'header_site_description', array(
'selector' => '.site-tagline',
'settings' => array( 'blogdescription' ),
'render_callback' => 'cactus_header_site_descriptione',
) );
$wp_customize->selective_refresh->add_partial( 'button_text_shop_selective', array(
'selector' => '.button_text_shop_selective',
'settings' => array( 'cactus[button_text_shop]' ),
'render_callback' => 'cactus_button_text_shop',
) );
$wp_customize->get_section ('title_tagline')->panel = 'panel-header';
//$wp_customize->get_section ('colors')->panel = 'panel-header';
$wp_customize->get_section ('header_image')->panel = 'panel-header';
}
add_action( 'customize_register', 'cactus_register_partials' );
/* section banner */
function cactus_video_title_banner(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['video_title_banner']) )
return $cactus_options['video_title_banner'];
}
function cactus_video_subtitle_banner(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['video_subtitle_banner']) )
return $cactus_options['video_subtitle_banner'];
}
function cactus_button_text_banner(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['button_text_banner']) )
return $cactus_options['button_text_banner'];
}
/*function cactus_button_link_banner(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['button_link_banner']) )
return $cactus_options['button_link_banner'];
}*/
/* section service */
function cactus_section_title_service(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_service']) )
return $cactus_options['section_title_service'];
}
function cactus_section_subtitle_service(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_service']) )
return $cactus_options['section_subtitle_service'];
}
/* section works */
function cactus_section_title_works(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_works']) )
return $cactus_options['section_title_works'];
}
function cactus_section_subtitle_works(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_works']) )
return $cactus_options['section_subtitle_works'];
}
/* section promo */
function cactus_section_title_promo(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_promo']) )
return $cactus_options['section_title_promo'];
}
function cactus_section_subtitle_promo(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_promo']) )
return $cactus_options['section_subtitle_promo'];
}
function cactus_text_promo(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['text_promo']) )
return $cactus_options['text_promo'];
}
function cactus_button_text_promo(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['button_text_promo']) )
return $cactus_options['button_text_promo'];
}
/* section team */
function cactus_section_title_team(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_team']) )
return $cactus_options['section_title_team'];
}
function cactus_section_subtitle_team(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_team']) )
return $cactus_options['section_subtitle_team'];
}
/* section counter */
function cactus_section_title_counter(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_counter']) )
return $cactus_options['section_title_counter'];
}
function cactus_section_subtitle_counter(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_counter']) )
return $cactus_options['section_subtitle_counter'];
}
/* section testimonial */
function cactus_section_title_testimonial(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_testimonial']) )
return $cactus_options['section_title_testimonial'];
}
function cactus_section_subtitle_testimonial(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_testimonial']) )
return $cactus_options['section_subtitle_testimonial'];
}
/* section news */
function cactus_section_title_news(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_news']) )
return $cactus_options['section_title_news'];
}
function cactus_section_subtitle_news(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_news']) )
return $cactus_options['section_subtitle_news'];
}
function cactus_button_text_news(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['button_text_news']) )
return $cactus_options['button_text_news'];
}
/* section contact */
function cactus_section_title_contact(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_contact']) )
return $cactus_options['section_title_contact'];
}
function cactus_section_subtitle_contact(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_contact']) )
return $cactus_options['section_subtitle_contact'];
}
function cactus_address_contact(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['address_contact']) )
return $cactus_options['address_contact'];
}
function cactus_email_contact(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['email_contact']) )
return $cactus_options['email_contact'];
}
function cactus_tel_contact(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['tel_contact']) )
return $cactus_options['tel_contact'];
}
/*section shop*/
function cactus_section_title_shop(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_title_shop']) )
return $cactus_options['section_title_shop'];
}
function cactus_section_subtitle_shop(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['section_subtitle_shop']) )
return $cactus_options['section_subtitle_shop'];
}
function cactus_button_text_shop(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['button_text_shop']) )
return $cactus_options['button_text_shop'];
}
function cactus_section_shop_selective(){
return cactus_shop_content(false);
}
/* footer */
function cactus_copyright(){
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if( isset($cactus_options['copyright']) )
return $cactus_options['copyright'];
}
//button_text_call_to_action
function cactus_header_site_title(){
return get_bloginfo( 'name' );
}
function cactus_header_site_descriptione(){
return get_bloginfo( 'description' );
}
function cactus_ajax_get_image_url(){
$id = $_POST['id'];
$image = $id;
if (is_numeric($id)) {
$image_attributes = wp_get_attachment_image_src($id, 'full');
$image = $image_attributes[0];
}
echo $image;
exit(0);
}
add_action('wp_ajax_cactus_ajax_get_image_url', 'cactus_ajax_get_image_url');
add_action('wp_ajax_nopriv_cactus_ajax_get_image_url', 'cactus_ajax_get_image_url');
/*
* Get header widgets
*/
function cactus_get_header_widgets( $key, $output = true ){
$widgets = cactus_option($key);
$html = '';
if(is_array($widgets) && !empty($widgets)):
$html = "";
foreach($widgets as $item):
$html .= '';
if($item['link']!=''){
$html .= '';
}
if($item['icon']!=''){
$html .= ' ';
}
$html .= esc_attr($item['text']);
if($item['link']!=''){
$html .= ' ';
}
$html .= ' ';
endforeach;
endif;
if( $output == true)
echo $html;
else
return $html;
}
/**
* Get WooCommerce products categories.
*
*/
function cactus_get_woo_categories() {
if ( ! class_exists( 'WooCommerce' ) ) {
return array();
}
$cactus_categories_array = array();
$cactus_prod_categories = get_categories(
array(
'taxonomy' => 'product_cat',
'hide_empty' => 1,
'title_li' => '',
)
);
if ( ! empty( $cactus_prod_categories ) ) {
foreach ( $cactus_prod_categories as $cactus_prod_cat ) {
if ( ! empty( $cactus_prod_cat->term_id ) && ! empty( $cactus_prod_cat->name ) ) {
$cactus_categories_array[ $cactus_prod_cat->term_id ] = $cactus_prod_cat->name;
}
}
}
return $cactus_categories_array;
}
/**
* Get content for shop section.
*
*/
function cactus_shop_content($echo = true) {
if ( !class_exists( 'WooCommerce' ) )
return '';
$cactus_options = get_option(CACTUS_TEXTDOMAIN);
if ( $echo == false ) ob_start();
?>
';
return;
}
$shop_items = isset($cactus_options['items_shop'])?$cactus_options['items_shop']:'4';
$args = array(
'post_type' => 'product',
);
$args['posts_per_page'] = ! empty( $shop_items ) ? absint( $shop_items ) : 4;
if(!is_numeric( $args['posts_per_page'] ))
$args['posts_per_page'] = 4;
$categories_shop = isset($cactus_options['categories_shop'])?$cactus_options['categories_shop']:'';
if ( sizeof( $categories_shop ) >= 1 && ! empty( $categories_shop[0] ) ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $categories_shop,
),
);
}
$order_shop = isset($cactus_options['order_shop'])?$cactus_options['order_shop']:'DESC';
if ( ! empty( $order_shop ) ) {
$args['order'] = $order_shop;
}
$orderby_shop = isset($cactus_options['orderby_shop'])?$cactus_options['orderby_shop']:'date';
if ( ! empty( $orderby_shop ) ) {
$args['orderby'] = $orderby_shop;
}
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
$i = 1;
while ( $loop->have_posts() ) {
$loop->the_post();
global $product;
global $post;
$id = get_the_ID();
$size = 'shop_catalog';
$gallery = get_post_meta($id, '_product_image_gallery', true);
$attachment_image = '';
if (!empty($gallery)) {
$gallery = explode( ',', $gallery );
$first_image_id = $gallery[0];
$attachment_image = wp_get_attachment_image( $first_image_id, $size, false, array( 'class' => 'hover-image' ) );
}
if (has_post_thumbnail()) {
$thumb = get_the_post_thumbnail(get_the_ID(), "shop_catalog");
$product_image = $thumb.$attachment_image;
} else {
$product_image = ' ';
}
?>
is_on_sale()) :
$onsale = apply_filters( 'woocommerce_sale_flash', '' . __( 'Sale!', 'cactus' ) . ' ', $post, $product );
endif;
echo $product_image;
?>
product_type,
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : ''
) ) );
woocommerce_template_loop_add_to_cart(array('class'=> 'button '.$add_to_cart_link_class));
?>
array(
'cactus-companion' => array(
'recommended' => true,
'description' => sprintf( esc_html__( 'Install and activate %s plugin to take full advantage of Cactus theme. More options could be found at Customize and page meta options.', 'cactus' ), sprintf( '%s ', 'Cactus Companion' ) ),
),
),
'recommended_actions' => array(),
'recommended_actions_title' => esc_html__( 'Recommended Actions', 'cactus' ),
'recommended_plugins_title' => esc_html__( 'Recommended Plugins', 'cactus' ),
'install_button_label' => esc_html__( 'Install and Activate', 'cactus' ),
'activate_button_label' => esc_html__( 'Activate', 'cactus' ),
'deactivate_button_label' => esc_html__( 'Deactivate', 'cactus' ),
);
Cactus_Customizer_Notify::init( apply_filters( 'cactus_customizer_notify_array', $config_customizer ) );
/**
* Include the TGM_Plugin_Activation class.
*/
if ( class_exists( 'TGM_Plugin_Activation' ) )
load_template( trailingslashit( get_template_directory() ) . 'inc/class-tgm-plugin-activation.php' );
//add_action( 'tgmpa_register', 'cactus_theme_register_required_plugins' );
/**
* Register the required plugins for this theme.
*
*/
function cactus_theme_register_required_plugins() {
$plugins = array(
array(
'name' => __('Cactus Companion','cactus'), // The plugin name
'slug' => 'cactus-companion', // The plugin slug (typically the folder name)
'source' => esc_url('https://downloads.wordpress.org/plugin/cactus-companion.zip'), // The plugin source
'required' => false, // If false, the plugin is only 'recommended' instead of required
'version' => '1.0.0', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
'external_url' => '', // If set, overrides default API URL and points to an external URL
),
);
/**
* Array of configuration settings. Amend each line as needed.
*/
$config = array(
'id' => 'cactus-companion', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to pre-packaged plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
/**
* Welcome notice.
*
*/
function cactus_welcome_notice() {
global $pagenow;
$theme = wp_get_theme();
if ( is_child_theme() ) {
$theme_name = $theme->parent()->get( 'Name' );
} else {
$theme_name = $theme->get( 'Name' );
}
$theme_version = $theme->get( 'Version' );
$theme_slug = $theme->get_template();
$cactus_welcome_notice = get_option('cactus_welcome_notice');
if($cactus_welcome_notice == '1')
return '';
if( $pagenow == "themes.php" && isset($_GET['page']) && $_GET['page'] == "cactus-welcome" ):
return '';
endif;
?>
Cactus Companion plugin.', esc_url('https://wordpress.org/plugins/cactus-companion/') );
?>
' . __('Go to Customize', 'cactus') . ' ';
?>
';
echo ''.esc_attr__('About Cactus', 'cactus' ).' ';
echo '
'.esc_attr__('Thanks for choosing Cactus theme!', 'cactus' ).'
Cactus is an easy-to-use theme which can help you create your site in minutes. In just simple steps. No code knowledge needed.
';
echo '';
}
/**
* Add script to the footer
*
*/
function cactus_footer_script(){
$display_scroll_to_top = cactus_option('display_scroll_to_top');
if($display_scroll_to_top=='1' || is_customize_preview() ){
$css_class = 'back-to-top';
if( $display_scroll_to_top !=1 && is_customize_preview() )
$css_class .= ' hide';
echo '
';
}
}
add_action('wp_footer','cactus_footer_script');
/**
* Add title bar
*
*/
function cactus_page_title_bar( $content, $type='page'){
$display_titlebar = cactus_option('display_titlebar');
if($display_titlebar==''||$display_titlebar==0)
return '';
$title_bar_layout = cactus_option('title_bar_layout');
$title_bar_layout = apply_filters('cactus_title_bar_layout',$title_bar_layout);
$class = 'page-title-bar '.$title_bar_layout;
$html = '';
$html .= '';
$html .= '
';
if($type=='page'){
$html .= '
';
$html .= ''.get_the_title().' ';
$html .= ' ';
}
$html .= '
';
ob_start();
cactus_breadcrumbs();
$html .= ob_get_contents();
ob_end_clean();
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
';
$html .= ' ';
return $html;
}
add_filter( 'cactus_page_title_bar', 'cactus_page_title_bar', 10, 2 );
/**
* Get separator
*
*/
function cuctus_get_separator($type = 'cloud', $color = '#fff', $height = '100' ){
$height = str_replace('px','',$height);
$class = "cactus-section-separator";
if($type == 'triangle-up')
$class .= " cactus-triangle-up";
if($type == 'triangle-down')
$class .= " cactus-triangle-down";
$html = '';
switch($type){
case "diagonal":
$html .= '
';
break;
case "diagonal-reverse":
$html .= '
';
break;
case "triangle-up":
$html .= '
';
break;
case "triangle-down":
$html .= '
';
break;
case "big-triangle-up":
$html .= '
';
break;
case "big-triangle-down":
$html .= '
';
break;
case "curve-up":
$html .= '
';
break;
case "curve-down":
$html .= '
';
break;
case "cloud":
$html .= '
';
break;
}
$html .= '
';
return $html;
}
/*
* Allow tags
*/
add_action('init', 'cactus_html_tags_code', 10);
function cactus_html_tags_code() {
global $allowedposttags;
$allowed_atts = array(
'align' => array(),
'class' => array(),
'type' => array(),
'id' => array(),
'dir' => array(),
'lang' => array(),
'style' => array(),
'xml:lang' => array(),
'src' => array(),
'alt' => array(),
'href' => array(),
'rel' => array(),
'rev' => array(),
'target' => array(),
'novalidate' => array(),
'type' => array(),
'value' => array(),
'name' => array(),
'tabindex' => array(),
'action' => array(),
'method' => array(),
'for' => array(),
'width' => array(),
'height' => array(),
'data' => array(),
'title' => array(),
);
$allowedposttags['form'] = $allowed_atts;
$allowedposttags["script"] = array("src" => array(),"name" => array(),"id" => array(),"type" => array());
$allowedposttags['iframe'] = array (
'align' => true,
'frameborder' => true,
'height' => true,
'width' => true,
'sandbox' => true,
'seamless' => true,
'scrolling' => true,
'srcdoc' => true,
'src' => true,
'class' => true,
'id' => true,
'style' => true,
'border' => true,
);
$allowedposttags["object"] = array("height" => array(), "width" => array());
$allowedposttags["param"] = array("name" => array(), "value" => array());
$allowedposttags["embed"] = array(
"src" => array(),
"type" => array(),
"allowfullscreen" => array(),
"allowscriptaccess" => array(),
"height" => array(),
"width" => array()
);
$allowedposttags["style"] = array("type" => array());
$allowedposttags["link"] = array("rel" => array(),"href" => array(),"id" => array(),"type" => array(),"media" => array());
$allowedposttags["input"] = array("name" => array(),"id" => array(),"value" => array(),"class" => array(),"placeholder" => array(),"required" => array(),"type" => array(),'aria-required' => array());
$allowedposttags["select"] = array("name" => array(),"id" => array(),"value" => array(),"class" => array(),"required" => array(),"type" => array(),'aria-required' => array());
$allowedposttags["textarea"] = array("name" => array(),"id" => array(),"value" => array(),"class" => array(),"placeholder" => array(),"required" => array(),"type" => array(),'aria-required' => array());
}
/**
* Convert Hex Code to RGB
* @param string $hex Color Hex Code
* @return array RGB values
*/
function cactus_hex2rgb( $hex ) {
if ( strpos( $hex,'rgb' ) !== FALSE ) {
$rgb_part = strstr( $hex, '(' );
$rgb_part = trim($rgb_part, '(' );
$rgb_part = rtrim($rgb_part, ')' );
$rgb_part = explode( ',', $rgb_part );
$rgb = array($rgb_part[0], $rgb_part[1], $rgb_part[2], $rgb_part[3]);
} elseif( $hex == 'transparent' ) {
$rgb = array( '255', '255', '255', '0' );
} else {
$hex = str_replace( '#', '', $hex );
if( strlen( $hex ) == 3 ) {
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
} else {
$r = hexdec( substr( $hex, 0, 2 ) );
$g = hexdec( substr( $hex, 2, 2 ) );
$b = hexdec( substr( $hex, 4, 2 ) );
}
$rgb = array( $r, $g, $b );
}
return $rgb;
}