',
'container_widgets_pieces',
'widget_corner widget_top_left',
'widget_token_left',
'widget_topbottom widget_top_center',
'widget_corner widget_top_right',
'widget_token_right',
'widget_sides widget_middle_left',
'widget_center widget_content',
'widget_sides widget_middle_right',
'widget_corner widget_bottom_left',
'widget_topbottom widget_bottom_center',
'widget_corner widget_bottom_right',
'widget_token_bottom'
);
$new_classes=array('
',
'container_widgets_pieces '.$reset_boxes,
'widget_corner widget_top_left '.$reset_boxes,
'widget_token_left '.$reset_boxes,
'widget_topbottom widget_top_center '.$reset_boxes,
'widget_corner widget_top_right '.$reset_boxes,
'widget_token_right '.$reset_boxes,
'widget_sides widget_middle_left '.$reset_boxes,
'widget_center widget_content '.$reset_boxes,
'widget_sides widget_middle_right '.$reset_boxes,
'widget_corner widget_bottom_left '.$reset_boxes,
'widget_topbottom widget_bottom_center '.$reset_boxes,
'widget_corner widget_bottom_right '.$reset_boxes,
'widget_token_bottom '.$reset_boxes
);
ob_start();
dynamic_sidebar($position);
$sidebar_contents = ob_get_clean();
echo str_replace($class_originals,$new_classes,$sidebar_contents);
}
function update_layout(){
$layout_pack=array();
foreach($GLOBALS['pages'] as $index => $page){//$GLOBALS['pages'] ver en functions/variables_load.php
if ($page->ID===0){// asignar slider para el single post,search,archive y category
$layout_pack[$page->ID]['slider_blog']=true;
$layout_pack[$page->ID]['slider_single']=true;
$layout_pack[$page->ID]['slider_search']=false;
$layout_pack[$page->ID]['slider_archive']=false;
$layout_pack[$page->ID]['slider_category']=false;
$layout_pack['themeshock_default_widget_boxes'] = true;
}
else{
$layout_pack[$page->ID]['slider_page']=true;/// asigna slider dependiendo el id del pageel blog o home el caso es el 0
}
$layout_pack[$page->ID]['footer_widget_style']=$GLOBALS['style_widgets_default'];//asignar estilos al footer
foreach($GLOBALS['sidebar_info'] as $position_widgets=> $description ){//asignar estilos y posiciones en el layout
$layout_pack[$page->ID][$position_widgets]['active']=($position_widgets==='right_1')?true:false;//define layout habilitado por default en este caso es right_1
$layout_pack[$page->ID][$position_widgets]['style']=$GLOBALS['style_widgets_default'];
}
}
update_option('themeshock_layout_options',maybe_serialize($layout_pack));//regitrar layout en los didebar
return $layout_pack;//carga todas las posiciones de los layouts;
}
function update_sidebar(){
$sidebars=array();
foreach($GLOBALS['position_lay_widgets'] as $position_widgets ){
$sidebars[$position_widgets]=$GLOBALS['register_sidebar'];
$sidebars[$position_widgets]['name']=$position_widgets;
}
update_option('themeshock_sidebar',maybe_serialize($sidebars));//registra un sidebar en las posisciones
return $sidebars;
}
function update_slider_info(){
$upload_dir=wp_upload_dir();
if (isset($upload_dir["error"]) && $upload_dir["error"]!==false ){
$GLOBALS['error_folder']= 'The option to change logo and slider is disabled, please create the following folder: /wp-content/uploads/ and allow writing by setting its permissions to 0777';
return false;
}
$directory_slider=$upload_dir['basedir']."/slider/";
mkdir($directory_slider,0777,true);
$directory_slider_base=get_template_directory()."/img/slider/{*.jpg,*.png,*.gif,*.bmp}";
$img_directory_pack=glob($directory_slider_base,GLOB_BRACE);
$slider_info= array();
foreach($img_directory_pack as $index => $img_slider_info){
$get_info_img=getimagesize($img_slider_info);
$slider_info[$index]['active']=true;
$slider_info[$index]['link']='#';
$slider_info[$index]['url']=$upload_dir['baseurl'].'/slider/'.basename($img_slider_info);
$slider_info[$index]['path']=$upload_dir['basedir'].'/slider/'.basename($img_slider_info);
@chmod($slider_info[$index]['path'],0777);
$slider_info[$index]['thumbnail']=$upload_dir['baseurl'].'/slider/'.basename(image_resize($slider_info[$index]['path'],200,200));
@chmod($slider_info[$index]['thumbnail'],0777);
}
update_option('themeshock_slider_dimensions',maybe_serialize($get_info_img));/// guarda las dimenssiones de la imagen
update_option('themeshock_slider_images',maybe_serialize($slider_info));
$GLOBALS['slider_img_info']=$slider_info;
return $slider_info;
}
function update_logo_info(){
$upload_dir=wp_upload_dir();
if (isset($upload_dir["error"]) && $upload_dir["error"]!==false ){
$GLOBALS['error_folder']= 'The option to change logo and slider is disabled, please create the following folder: /wp-content/uploads/ and allow writing by setting its permissions to 0777';
return false;
}
$directory_logo=$upload_dir['basedir'].'/logo/';
$get_img_logo=get_template_directory_uri().'/img/logo/logo.png';
$get_dimmensions=getimagesize($get_img_logo);
$logo_info['path']=$upload_dir['basedir'].'/logo/logo.png';
$logo_info['url']=$upload_dir['baseurl'].'/logo/logo.png';
$logo_info['size']=$get_dimmensions;
@mkdir($directory_logo,0777,true);
chmod($logo_info['path'],0777);
update_option('themeshock_logo',maybe_serialize($logo_info));
return $logo_info;
}
function display_elements($element_block){
if(isset($GLOBALS['display_elements']) && $_SERVER['SERVER_NAME'] == 'www.wpthemegenerator.com'){
switch($GLOBALS['display_elements'][$element_block]){
case 'show':
return 'show_element';
break;
case 'hide':
return 'hide_element';
break;
}
}
}
function get_attr_logo(){
$eff_logo = $style_logo = $img_logo = NULL;
if($GLOBALS['logo_type'] == 'text'){
$eff_logo = 'logo_effect_'.strtolower($GLOBALS['logo_text_options']['logo_effect']);
$style_logo = 'font-size: '.$GLOBALS['logo_text_options']['logo_text_font_size'].';';
if($GLOBALS['logo_text_options']['logo_font_family'] != 'Default'){
$style_logo .= 'font-family: "'.$GLOBALS['logo_text_options']['logo_font_family'].'", sans-serif;';
}
};
$style_attr = ($style_logo != "")?"style='".$style_logo."'":"";
$src_logo = ($GLOBALS['logo_info'])?$GLOBALS['logo_info']['url']:get_template_directory_uri();
if($GLOBALS['logo_type'] == 'image'){
$img_logo = '

';
}else{
$img_logo = '
'.$GLOBALS['logo_text_options']['logo_text'].'';
}
return '
'.$img_logo.'';
}
function trim_excerpt($text) {
return str_replace(" [...]", '...', $text);
}
add_filter('get_the_excerpt', 'trim_excerpt');
function trim_the_content( $the_contents, $read_more_tag = ' READ MORE...', $perma_link_to = '', $all_words = 45 ) {
$allowed_tags = array( 'a', 'abbr', 'b', 'blockquote', 'b', 'cite', 'code', 'div', 'em', 'fon', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'label', 'i', 'p', 'pre', 'span', 'strong', 'title', 'ul', 'ol', 'li', 'object', 'embed', 'input' );
if( $the_contents != '' ) {
$allowed_tags = '<' . implode( '><', $allowed_tags ) . '>';
$the_contents = str_replace( ']]>', ']]>', $the_contents );
$the_contents = strip_tags( $the_contents, $allowed_tags );
if( $all_words > count( preg_split( '/[\s]+/', strip_tags( $the_contents ), -1 ) ) ) return $the_contents;
$all_chunks = preg_split( '/([\s]+)/', $the_contents, -1, PREG_SPLIT_DELIM_CAPTURE );
$the_contents = '';
$count_words = 0;
$enclosed_by_tag = false;
foreach( $all_chunks as $chunk ) {
if( 0 < preg_match( '/<[^>]*$/s', $chunk ) ) $enclosed_by_tag = true;
elseif( 0 < preg_match( '/>[^<]*$/s', $chunk ) ) $enclosed_by_tag = false;
if( !$enclosed_by_tag && '' != trim( $chunk ) && substr( $chunk, -1, 1 ) != '>' ) $count_words ++;
$the_contents .= $chunk;
if( $count_words >= $all_words && !$enclosed_by_tag ) break;
}
$the_contents = $the_contents . '
' . $read_more_tag . '';
$the_contents = force_balance_tags( $the_contents );
}
return $the_contents;
}
function statusCustomPostType($wtsPostName, $wtsStatus){
global $wpdb, $post;
(isset($_POST['themeshock_enablePostTypeGallery']) || isset($_POST['themeshock_enablePostTypePortfolio']) || isset($_POST['themeshock_enablePostTypeServices']) || isset($_POST['themeshock_enablePostTypeProducts']) ||
isset($_POST['themeshock_enablePostTypeTestimonials']))?$redirect_warr = 'true':$redirect_warr = 'false';
if (is_user_logged_in()){
$wpdb->query("
UPDATE $wpdb->posts
SET post_status = '".$wtsStatus."'
WHERE post_name = '".$wtsPostName."';"
);
$menu_current = get_theme_mod('nav_menu_locations');
if($menu_current['shock_menu'] != 0){
$term_shock_menu = get_term_by('term_id', $menu_current['shock_menu'], 'nav_menu');
$idsPostNameWts = $wpdb->get_results("SELECT ID FROM wp_posts w where post_name like '%wts%' and post_status = 'trash'");
$resultMenuItems = $wpdb->get_results($wpdb->prepare("SElECT post_id, meta_value FROM wp_term_relationships rs, wp_postmeta pm where rs.term_taxonomy_id = %s and rs.object_id = pm.post_id and meta_key = '_menu_item_object_id';", $term_shock_menu->term_taxonomy_id));
foreach($idsPostNameWts as $idPostName){
foreach($resultMenuItems as $resultMenuItem){
if($resultMenuItem->meta_value === $idPostName->ID){
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %s;", $resultMenuItem->post_id));
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->posts WHERE id = %s;", $resultMenuItem->post_id));
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %s;", $resultMenuItem->post_id));
}
}
}
($redirect_warr === 'true')?header('Location: '.$_SERVER['REQUEST_URI']):'';
}
}
}
function activeCustomPostType($CustomPostType, $wtsPostType, $wtsPostName){
global $wpdb;
if(get_option('themeshock_enablePostType'.$CustomPostType) === 'true'):
statusCustomPostType($wtsPostName, 'publish');
add_action('init', $wtsPostType);
else:
statusCustomPostType($wtsPostName, 'trash');
remove_action('init', $wtsPostType);
endif;
}
function is_wpthemegenerator(){
if($_SERVER['HTTP_HOST'] == 'www.wpthemegenerator.com'){
return true;
}else{
return false;
}
}
include 'functions/framework-tool-panel.php';
get_template_part('functions/sidebars');
get_template_part('functions/taxonomies');
get_template_part('functions/shortcodes');
get_template_part('functions/widgets');
?>