self['IS_LOCAL'] = true; $splode = explode('\\',$dir); }else{ $this->self['IS_LOCAL'] = false; $splode = explode('/',$dir); } $this->self['DIR'] = $dir.'/'; $dex = count($splode)-1; $this->self['FOLDER'] = $splode[$dex]; if($this->is_plugin()){ $this->self['PATH'] = plugins_url($this->self['FOLDER'])."/"; }else{ $this->self['PATH'] = $this->get_site_template_url().'/'; } if($prefix==''){$prefix = $this->get_dir_name();} $this->self['prefix'] = $prefix; $this->self['BAD_CHARS'] = array('•','
','
','<','>','&','\\','"',"'",';'); $this->self['NEW_CHARS'] = array('(_BL_)','(_BR_)','(_HR_)','(_LT_)','(_GT_)','(_AM_)','(_BS_)','(_DQ_)','(_SQ_)','(_SC_)'); $this->self['BAD_CHARS_64'] = array('•','
','
','<','>','&','\\','"',"'",';','/','+'); $this->self['NEW_CHARS_64'] = array('(_BL_)','(_BR_)','(_HR_)','(_LT_)','(_GT_)','(_AM_)','(_BS_)','(_DQ_)','(_SQ_)','(_SC_)','(_FS_)','(_PL_)'); $this->self['TURNOFFS'] = array(); $this->use_gamma(); } private function url_get_contents($url){ $response = wp_remote_get($url); return $this->get_value($response,'body'); } function import_image($post_id,$name,$image){ $attach_id = $this->attach_image($image,$post_id,$name); $this->set_featured_image($post_id, $attach_id); return $attach_id; } function attach_image($url,$post_id,$desc='',$how=''){ require_once(ABSPATH . 'wp-admin/includes/media.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); //$url = ''; // Input a .zip URL here $tmp = download_url($url); preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); $filename = basename($this->get_value($matches,0)); if($filename!=''){ $splode = explode('.',$filename); $spcnt = count($splode); $fdex = $spcnt-1; $filetype = strtolower($splode[$fdex]); $filename = $this->canonize($desc).'.'.$filetype; $file_array = array( 'name' => $filename, 'tmp_name' => $tmp ); // Check for download errors if ( is_wp_error( $tmp ) ) { @unlink( $file_array[ 'tmp_name' ] ); return $tmp; } $id = media_handle_sideload( $file_array, $post_id ); // Check for handle sideload errors. if ( is_wp_error( $id ) ) { @unlink( $file_array['tmp_name'] ); return $id; } if($how=='src' or $how=='url'){ return wp_get_attachment_url( $id ); } return $id; } return NULL; } function is_user_logged_in() { $user = wp_get_current_user(); return $user->exists(); } function is_user_admin(){ if(is_user_logged_in() and current_user_can('manage_options')){return true;} return false; } function get_attachment_id_by_src($src,$stat=''){ $parsed_url = explode(parse_url(WP_CONTENT_URL,PHP_URL_PATH),$src); $this_host = str_ireplace('www.','',parse_url(home_url(),PHP_URL_HOST)); $file_host = str_ireplace('www.','',parse_url($src,PHP_URL_HOST)); if(!isset($parsed_url[1]) || empty($parsed_url[1]) || ($this_host!=$file_host)){return '';} global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->prefix}posts WHERE guid RLIKE %s;",$parsed_url[1])); $attachment_id = $attachment[0]; $imgdata = wp_get_attachment_metadata($attachment_id); $wid = $this->get_value($imgdata,'width'); $hit = $this->get_value($imgdata,'height'); if($stat=='width'){return $wid;} if($stat=='height'){return $hit;} return array('width'=>$wid,'height'=>$hit); } function get_post_category($post_id=NULL,$how='',$what=''){ if($post_id==NULL){$post_id = get_the_ID();} $cats = array(); $cat = ''; $cid = ''; $dep = 0; $ctgy = get_the_category($post_id); if($how=='all'){ $cats = $ctgy; }else if($how=='base'){ $dep = 1000; }else{ $dep = -1; } foreach($ctgy as $rex=>$vex){ $catid = $vex->cat_ID; $ndep = $this->get_category_depth($catid); if($dep!=$ndep){ if($how=='all'){ if($cat!=''){$cat .= ',';} $cat .= $vex->cat_name; if($cid!=''){$cid .= ',';} $cid .= $catid; }else{ $isdep = false; if($how=='base'){ if($ndep<$dep){ $isdep = true; } }else{ if($ndep>$dep){ $isdep = true; } } if($isdep==true){ $dep = $ndep; $cat = $vex->cat_name; $cid = $catid; $cats = $vex; } } } } if($what=='array'){ return $cats; }else if($what=='id'){ return $cid; }else{ return $cat; } } function get_category_id($category=NULL){ if($category==NULL){$category = single_term_title("", false);} return get_cat_ID( $category ); } function get_category_ids($post_id=NULL){ return $this->get_taxonomy_ids('category',$post_id); } function get_taxonomy_ids($tax='category',$post_id=NULL){ if($post_id==NULL){$post_id = get_the_ID();} $terms = get_the_terms($post_id,$tax); $ids = array(); if(!empty($terms)){ foreach($this->object_to_array($terms) as $term){ $ids[] = $term['term_id']; } } return $ids; } function get_category_title($cat_id=NULL) { if($cat_id==NULL){$cat_id = $this->get_category_id();} return get_cat_name($cat_id); } function get_category_description($cat_id=NULL) { if($cat_id==NULL){$cat_id = $this->get_category_id();} return category_description($cat_id); //$cat_id = (int) $cat_id; //$category = &get_category($cat_id); //return $category->description; } function get_category_depth($cat_id=NULL){ if($cat_id==NULL){$cat_id = $this->get_category_id();} $max_depth_to_test = intval(9); //set this to highest depth you might have $last_depth = 0; $cat_to_test = $cat_id; $category = get_category($cat_to_test); for ( $counter = 1; $counter <= $max_depth_to_test; $counter += 1) { if ($category->category_parent) { $category=get_category($category->category_parent); $last_depth = $counter; } } $last_depth +=1; return $last_depth; } function get_category_data($id=NULL,$var=''){ return $this->get_taxonomy_data('category',$id,$var); } function get_category_link($term_id=NULL){ return $this->get_taxonomy_link('category',$term_id); } function get_category_link_path($term_id,$slug=''){// NOTUSED return $this->get_taxonomy_link_path('category',$term_id,$slug); } function get_taxonomy_data($tax='category',$id=NULL,$var=''){ if($id==NULL){ $how = 'name'; $id = single_term_title("", false); }else{ $how = 'term_id'; } $category_data = get_term_by($how,$id,$tax); if($var==''){return $category_data;} if(is_object($category_data)){ return $category_data->$var; }else{ return $this->get_value($category_data,$var); } } function get_taxonomy_link($tax='category',$term_id=NULL){ if($term_id==NULL){$term_id = $this->get_category_id();} $catslug = $this->get_taxonomy_link_path($tax,$term_id); if($tax=='category'){ return $this->get_site_base_url().'/category/'.$catslug; }else{ return $this->get_site_base_url().'/'.$catslug; } } function get_taxonomy_link_path($tax='category',$term_id=NULL,$slug=''){ if($term_id==NULL){$term_id = $this->get_category_id();} $cat = $this->get_taxonomy_data($tax,$term_id); $pslug = $this->get_value($cat,'slug'); $parent = $this->get_value($cat,'parent'); if($pslug!=''){ $slug = $pslug.'/'.$slug; if($parent!=0){ $slug = $this->get_taxonomy_link_path($tax,$parent,$slug); } } return $slug; } function get_breadcrumb_separator(){ $sep = $this->htmlout($this->get_customizer_setting('seo_breadcrumbsep')); if(substr($sep,0,3)=='fa-'){return '';} return ''.$sep.''; } function get_category_breadcrumbs($term_id=NULL,$strg='',$com='',$markup=true){ if($term_id==NULL){$term_id = $this->get_category_id();} $cat = $this->get_category_data($term_id); $slug = $this->get_value($cat,'slug'); $parent = $this->get_value($cat,'parent'); $name = $this->get_value($cat,'name'); $count = $this->get_value($cat,'count'); $link = $this->get_category_link($term_id); if($markup==false){ $href = ''.$name.''; //$blank = ''.$name.''; $blank = ''.$name.''; }else{ $href = ''.$name.''; $href = ''.$name.''; $blank = ''.$name.''; } if($slug!=''){ if($strg=='' and $com==''){ $strg = $blank; }else{ $strg = $href.' '.$this->get_breadcrumb_separator().' '.$strg; } if($parent!=0){ $strg = $this->get_category_breadcrumbs($parent,$strg,$com,$markup); } } return $strg; } function inline_markup($is,$isnt=''){ $in = false; $isinline = $this->get_customizer_setting('seo_inlinemarkup'); if($isinline!=''){$in = true;} if($in==true){return $is;} return $isnt; } function get_markup($mark,$how,$what=''){ if($this->inline_markup('yes')==''){return '';} if($how=='type'){ return ' itemscope itemtype="http://schema.org/'.$mark.'"'; }else if($how=='prop'){ return ' itemprop="'.$mark.'"'; }else if($how=='rel'){ return ' rel="v:'.$mark.'"'; } return ''; } function generate_breadcrumbs(){ if(is_home() or is_front_page()){return '';} if(function_exists('yoast_breadcrumb')){ $crumbs = yoast_breadcrumb('','',false); if($crumbs!=''){ $crumbs = preg_replace('!xmlns:v="(.*?)"!s','',$crumbs); $crumbs = preg_replace('!typeof="(.*?)"!s','',$crumbs); $crumbs = preg_replace('!property="(.*?)"!s','',$crumbs); $crumbs = preg_replace('!rel="(.*?)"!s','',$crumbs); return ''; } } $RAT = ''; $blist = $this->get_markup('BreadcrumbList','type'); $llist = $this->get_markup('ListItem','type'); $aline = $this->get_markup('url','rel'); $iline = $this->get_markup('item','prop'); $nline = $this->get_markup('name','prop'); $markup = false;if($this->inline_markup('yes')=='yes'){$markup = true;} $RAT .= ''; return $RAT; } function init(){ if($this->has_customizer_settings()){ add_action('customize_register',array(&$this,'init_customizer_settings')); } if($this->has_cron()){ add_filter( 'cron_schedules', array(&$this,'custom_cron_schedules')); foreach($this->self['cron_list'] as $fct=>$interval){ $action = $fct.'_cron'; add_action($action, $fct); if(!wp_next_scheduled($action)){ wp_schedule_event( time(), $interval, $action); } } } $this->runit('extends_init'); // may be a good idea to implement these again... see old _base.php file for more /* if($this->has_taxonomies()){ add_action('init',array(&$this,'init_taxonomies')); add_filter('archive_template',array(&$this,'taxonomy_template')); } if($this->has_landing_pages()){ add_action('init',array(&$this,'init_landing_pages')); if(is_admin()){ add_action('admin_head-post.php',array(&$this,'hide_landing_page_publishing_actions')); add_action('admin_head-post-new.php',array(&$this,'hide_landing_page_publishing_actions')); add_action('admin_head-edit.php',array(&$this,'hide_landing_page_list_actions')); add_action('save_post',array(&$this,'prevent_landing_page_conflict')); } } */ } function register_customizer_section($sect,$params=array()){$this->self['customizer_sections'][$sect] = $params;} function register_customizer_setting($setting,$params=array()){$this->self['customizer_settings'][$setting] = $params;} function has_customizer_settings(){if(isset($this->self['customizer_settings'])){if(count($this->self['customizer_settings'])>0){return true;}}return false;} function get_customizer_setting($setting,$default=NULL){ $mod = get_theme_mod($setting); if($mod==''){ if($default!=NULL){ $mod = $default; }else{ if(isset($this->self['customizer_settings'][$setting])){ $mod = $this->get_value($this->self['customizer_settings'][$setting],'default'); } } } return $mod; } function get_customizer_settings($mod){return $this->get_value($this->self['customizer_settings'],$mod,array());} function init_customizer_settings($wp_customize){ if($this->has_customizer_settings()){ // section priority can be set, but is built in registration order if not set $secprio = 1; foreach($this->self['customizer_sections'] as $section=>$data){ $title = $this->get_value($data,'title'); $prio = $this->get_value($data,'priority'); if($prio==''){$prio = $secprio;$secprio += 1;} $wp_customize->add_section($section,array('title'=>$title,'priority'=>$prio)); } $wp_customize->remove_section('colors'); $wp_customize->remove_section('header_image'); $wp_customize->remove_section('background_image'); // reorganize settings by section, it ignores setting that did not register a section $bysect = array(); foreach($this->self['customizer_settings'] as $setting=>$data){ $sect = $this->get_value($data,'section'); if($sect!=''){ if(!isset($bysect[$sect])){$bysect[$sect] = array();} $bysect[$sect][$setting] = $data; } } // create settings while setting priority to display in order that settings were registered if(count($bysect)>0){ foreach($bysect as $sect=>$sets){ $dex = 1; foreach($sets as $setting=>$data){ $data['priority'] = $dex; $dex += 1; $this->create_customizer_setting($setting,$data); } } } } } function init_customizer_head($raw=''){ if($this->has_customizer_settings()){ $css = ''; $js = ''; foreach($this->self['customizer_settings'] as $setting=>$data){ $acss = $this->get_value($data,'css'); if($acss!=''){ if(strstr($acss,'[[VALUE]]')){ $val = $this->get_customizer_setting($setting); $css .= str_replace('[[VALUE]]',$val,$acss); }else{ $css .= $this->function_call($acss); } } $ajs = $this->get_value($data,'js'); if($ajs!=''){ if(strstr($ajs,'[[VALUE]]')){ $val = $this->get_customizer_setting($setting); $js .= str_replace('[[VALUE]]',$val,$ajs); }else{ $js .= $this->function_call($ajs); } } } if($raw=='css'){ echo $css; }else if($raw=='js'){ echo $js; }else{ if($css!=''){echo '';} if($js!=''){echo '';} } } } function create_customizer_setting($id,$params){// WPFIX global $wp_customize; $type = $this->get_value($params,'type'); $sec = $this->get_value($params,'section'); $title = $this->get_value($params,'title'); $def = $this->get_value($params,'default'); $prio = $this->get_value($params,'priority'); $choices = $this->get_value($params,'choices'); $desc = $this->get_value($params,'description'); $live = $this->get_value($params,'live',false); $theme = $this->self['prefix']; if($id!='' and $type!='' and $sec!=''){ $transport = 'refresh'; if($live==true){$transport = 'postMessage';} if($type=='color'){ $wp_customize->add_setting($id,array('default' => $def , 'transport' => $transport , 'sanitize_callback' => 'sanitize_hex_color')); }else{ $wp_customize->add_setting($id,array('default' => $def , 'transport' => $transport , 'sanitize_callback' => 'sanitize_text_field')); //$wp_customize->add_setting($id,array('default' => $def , 'transport' => $transport , 'sanitize_callback' => '__return_false')); } $pass = array('label'=>$title,$theme,'section'=>$sec,'settings'=>$id); if($prio!=''){$pass['priority'] = $prio;} if($choices!=''){$pass['choices'] = $choices;} if($desc!=''){$pass['description'] = $desc;} if($type=='color'){ $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,$id,$pass)); }else if($type=='image'){ $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize,$id,$pass)); }else{ $pass['type'] = $type; $wp_customize->add_control($id,$pass); } } } function sanitize_callback($val){return $val;}// WPFIX function use_gamma(){$this->add_custom_data_table('gamma',array('Type'=>'varchar(10)','Var'=>'varchar(100)','Val'=>'text','Ymd'=>'varchar(8)'));} function get_gamma($var){ $arr = $this->queryit('select','gamma',array('Var'=>$var)); $type = $this->get_value($arr,array(0,'Type')); if($type=='setting'){ return $this->get_value($arr,array(0,'Val')); }else{ if(count($arr)>0){ $RET = array(); foreach($arr as $data){ $val = $this->get_value($data,'Val'); if($val!=''){ $RET[] = $this->htmlout($val); } } if(count($RET)>0){ return $RET; } } } return ''; } function set_gamma($var,$val){ $ymd = date('Ymd'); if(is_array($val)){ $this->queryit('delete','gamma',array('Var'=>$var)); //$this->reset_auto_increment('gamma','id'); if(count($val)>0){ foreach($val as $ins){ $ins = $this->htmlin($ins); $this->queryit('insert','gamma',array('Var'=>$var,'Val'=>$ins,'Ymd'=>$ymd)); } } }else{ $arr = $this->queryit('select','gamma',array('Var'=>$var)); $id = $this->get_value($arr,array(0,'id')); $val = $this->htmlin($val); if($id==''){ $this->queryit('insert','gamma',array('Type'=>'setting','Var'=>$var,'Val'=>$val,'Ymd'=>$ymd)); }else{ $this->queryit('update','gamma',array('Val'=>$val,'Ymd'=>$ymd),array('id'=>$id)); } } } function drop_gamma($var,$val){ $val = $this->htmlin($val); $this->queryit('delete','gamma',array('Var'=>$var,'Val'=>$val)); } function has_nav_menu($location,$com=''){ $isok = false; if(has_nav_menu($location)){ if($com=='assigned'){return true;} if(wp_nav_menu(array('theme_location'=>$location,'echo'=>false))!==false){ $isok = true; }else{ if($com=='empty'){return true;} } } return $isok; } function get_page_title($id=NULL){ if(is_category()){return $this->get_category_title($id);} if(is_tag()){$tag = get_tag($id);if(isset($tag->name)){return $tag->name;}else{return '';}} if(is_tax()){return $this->get_category_title($id);} return get_the_title($id); } function get_slug_from_url($url){ $str = explode('?',$url); $base = $str[0]; $str = explode('#',$base); $base = $str[0]; $blog = $this->get_site_base_url(); if($base==$blog or $base.'/'==$blog or $base==$blog.'/' or $base.'/'==$blog.'/'){return '';} $parts = explode('/',$base); $last = ''; foreach($parts as $part){ if($part!=''){$last = $part;} } return $last; } function UR_exists($url){ $headers=get_headers($url); return stripos($headers[0],"200 OK")?true:false; } function isHex($input){ if(substr($input,0,1)=='#'){return true;} return false; } function isRGB($input){ if(substr($input,0,3)=='rgb'){return true;} return false; } function rgbToHex($rgb){ $rgb = $this->rgbToArray($rgb); return '#' . sprintf('%02x', $rgb['r']) . sprintf('%02x', $rgb['g']) . sprintf('%02x', $rgb['b']); } function rgbToArray($rgb){ if(is_string($rgb)){ $str = str_replace(array('rgb(',')',' '),array('','',''),$rgb); $exp = explode(',',$str); $rgb = array('r'=>$exp[0],'g'=>$exp[1],'b'=>$exp[2]); } return $rgb; } function hexToRGB($hex) { $hex = str_replace("#", "", $hex); if(strlen($hex) == 3) { $r = hexdec($hex[0].$hex[0]); $g = hexdec($hex[1].$hex[1]); $b = hexdec($hex[2].$hex[2]); } else { $r = hexdec($hex[0].$hex[1]); $g = hexdec($hex[2].$hex[3]); $b = hexdec($hex[4].$hex[5]); } return array('r'=>$r, 'g'=>$g, 'b'=>$b); } function get_excerpt_by_id($post_id,$excerpt_length=20){ $the_post = get_post($post_id); //Gets post ID $the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt $the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images $the_excerpt = $this->string_limit_words($the_excerpt,$excerpt_length); return $the_excerpt; } function string_limit_words($string, $word_limit){ $words = explode(' ', $string, ($word_limit + 1)); if(count($words) > $word_limit) array_pop($words); return implode(' ', $words); } function is_feed(){ $red = $this->get_value($_SERVER,"REDIRECT_URL"); $reds = explode('/',$red); $page = 'feed'; $cnt = (strlen($page)+1); $cnts = ($cnt+1); if($cnt>0){ $end = substr($red,-$cnt,$cnt); $ends = substr($red,-$cnts,$cnts); if($end=='/'.$page or $ends=='/'.$page.'/'){ return true; } } return false; } function current_page_url() { $pageURL = 'http'; if( isset($_SERVER["HTTPS"]) ) { if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } function canonize($txtin){ $txtin = str_replace('.','',$txtin); $txtin = preg_replace('/\s\s+/', ' ', $txtin);// remove excess whitespace $txtin = preg_replace('/[^a-zA-Z0-9 \-\/\_]/','',$txtin);// remove all punctuation except -_/ $txtin = trim(strtolower($txtin));// trim removes beginning and ending whitespace $txtin = str_replace(" ","-",$txtin);// replace blanks with dashes return str_replace("-/","/",$txtin);// remove excess dashes that fall before slashes } function add_custom_data_table($table,$fields=''){ global $wpdb; $fieldlist = $this->parse_args($fields); $table_name = $wpdb->prefix.$this->self['prefix'].'_'.$table; $cols = $this->get_table_fields($table_name); if(count($cols)>0){ if(count($fieldlist)>0){ // ADD FIELDS THAT WEREN'T ALREADY THERE foreach($fieldlist as $k=>$v){ $var = $v; $typ = 'text'; if(is_string($k)){ $var = $k; $typ = $v; } if(!in_array($var,$cols)){ $wpdb->query("ALTER TABLE $table_name ADD $var $typ NOT NULL;"); } } // REMOVE FIELDS THAT ARE NO LONGER SPECIFIED foreach($cols as $k=>$v){ //if(!in_array($v,$fieldlist)){ if(!isset($fieldlist[$v])){ if($v!='id' and $v!='pid' and $v!='time'){ $wpdb->query("ALTER TABLE $table_name DROP $v"); } } } } }else{ $fieldstr = ''; if(count($fieldlist)>0){ foreach($fieldlist as $k=>$v){ //$fieldstr .= $v.' text NOT NULL,'; $fieldstr .= $k.' '.$v.' NOT NULL,'; } } $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, pid mediumint(9) NOT NULL, time int(12) NOT NULL, $fieldstr UNIQUE KEY id (id));"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } if($table!='post_data'){ if(!isset($this->self['custom_data_tables'][$table])){ $this->self['custom_data_tables'][$table] = array(); $this->self['custom_data_tables'][$table]['name'] = $table_name; $this->self['custom_data_tables'][$table]['fieldlist'] = $fields; $this->self['custom_data_tables'][$table]['fields'] = array(); } } } function get_table_fields($table_name){ global $wpdb; $RET = array(); $sql = "SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='".DB_NAME."' AND `TABLE_NAME`='".$table_name."';"; $arr = $wpdb->get_results($sql,ARRAY_A); if(count($arr)>0){ foreach($arr as $d=>$dat){ foreach($dat as $k=>$v){ $RET[] = $v; } } } return $RET; } function get_table_name($table){ global $wpdb; if($table=='post' or $table=='posts'){ $table_name = $wpdb->prefix.'posts'; }else if(isset($this->self['custom_data_tables'][$table])){ $table_name = $wpdb->prefix.$this->self['prefix'].'_'.$table; }else{ $table_name = $wpdb->prefix.$table; } return $table_name; } function parse_args($args,$delim='&'){ if(is_string($args)){ $RET = array(); $pairs = explode($delim,$args); if(count($pairs)>0){ foreach($pairs as $k=>$v){ $spl = explode('=',$v); if(count($spl)==2){ $dex = $spl[0]; $vex = $spl[1]; $RET[$dex] = $vex; } } } return $RET; }else if(is_object($args)){ return $this->object_to_array($args); }else if(is_array($args)){ return $args; } return array(); } function img_encrypt($nstr) { if(is_array($nstr)){ if(count($nstr)>0){ foreach($nstr as $dex=>$data){ $nstr[$dex] = $this->img_encrypt($data); } } }else{ for($cc=0;$ccself['BAD_CHARS_64']);$cc++){ $narr = explode($this->self['BAD_CHARS_64'][$cc],$nstr); $nstr = implode($this->self['NEW_CHARS_64'][$cc],$narr); } } return $nstr; } function img_decrypt($nstr) { if(is_array($nstr)){ if(count($nstr)>0){ foreach($nstr as $dex=>$data){ $nstr[$dex] = $this->img_decrypt($data); } } }else{ for($cc=0;$ccself['NEW_CHARS_64']);$cc++){ $narr = explode($this->self['NEW_CHARS_64'][$cc],$nstr); $nstr = implode($this->self['BAD_CHARS_64'][$cc],$narr); } $nstr = stripslashes($nstr); } return $nstr; } function htmlin($nstr) { if(is_array($nstr)){ if(count($nstr)>0){ foreach($nstr as $dex=>$data){ $nstr[$dex] = $this->htmlin($data); } } }else{ for($cc=0;$ccself['BAD_CHARS']);$cc++){ $narr = explode($this->self['BAD_CHARS'][$cc],$nstr); $nstr = implode($this->self['NEW_CHARS'][$cc],$narr); } } return $nstr; } function htmlout($nstr) { if(is_array($nstr)){ if(count($nstr)>0){ foreach($nstr as $dex=>$data){ $nstr[$dex] = $this->htmlout($data); } } }else{ for($cc=0;$ccself['NEW_CHARS']);$cc++){ $narr = explode($this->self['NEW_CHARS'][$cc],$nstr); $nstr = implode($this->self['BAD_CHARS'][$cc],$narr); } $nstr = stripslashes($nstr); } return $nstr; } function has_bad_chars($string){ $isthere = false; for($cc=0;$ccself['BAD_CHARS']);$cc++){ if (strpos($string,$this->self['BAD_CHARS'][$cc])) { $isthere = true; } } return $isthere; } function has_new_chars($string){ $isthere = false; for($cc=0;$ccself['NEW_CHARS']);$cc++){ if (strpos($string,$this->self['NEW_CHARS'][$cc])) { $isthere = true; } } return $isthere; } function strip_bad_chars($nstr) { for($cc=0;$ccself['BAD_CHARS']);$cc++){ $nstr = str_replace($this->self['NEW_CHARS'][$cc],"",$nstr); } return $nstr; } function strip_html($varin) { $varout = ""; $started = false; $ctr = strlen($varin); for ($ss=0; $ss<$ctr; $ss++) { $chk = substr($varin, $ss, 1); if ($chk == "<") { $started = true; } if ($started == false) { $varout .= $chk; } if ($chk == ">") { $started = false; } } return $varout; } function runit($fct,$pass=''){ if(method_exists($this,$fct)){ if($pass!=''){ call_user_func(array($this, $fct), $pass); }else{ call_user_func(array($this, $fct)); } }else if(function_exists($fct)){ if($pass!=''){ call_user_func($fct,$pass); }else{ call_user_func($fct); } } } function function_call($fct,$pass=''){ if(method_exists($this,$fct)){ if($pass!=''){ return call_user_func(array($this, $fct), $pass); }else{ return call_user_func(array($this, $fct)); } }else if(function_exists($fct)){ if($pass!=''){ return call_user_func($fct,$pass); }else{ return call_user_func($fct); } } return $fct; } function is_plugin(){ $dir = $this->self['DIR']; if(strstr($dir,'wp-content/plugins/') or strstr($dir,'wp-content\\plugins\\')){ return true; } return false; } function is_local(){ if(getenv('REMOTE_ADDR')=="127.0.0.1"){ return true; }else{ return false; } } function get_dir(){return $this->self['DIR'];} function get_dir_name(){return $this->last_page_in_url($this->self['DIR']);} function last_page_in_url($url=NULL){ if($url==NULL){$url = $this->current_page_url();} $drop = explode('?',$url); $splt = explode('/',$drop[0]); $cnt = count($splt)-1; $last = $splt[$cnt]; if($last==''){ $last = $splt[($cnt-1)]; } return $last; } function get_value($incoming,$var,$def=''){ if(is_object($incoming) and is_array($var)){$incoming = $this->object_to_array($incoming);} if (is_object($incoming)) { if(isset($incoming->$var)){ return $incoming->$var; } }else{ if(is_array($var)){ if(count($var)>0){ $tar = $incoming; foreach($var as $far){ if(isset($tar[$far])){ $tar = $tar[$far]; }else{ return $def; } } return $tar; } }else{ if(isset($incoming[$var])){ return $incoming[$var]; } } } return $def; } function set_and_true($arr,$var){if(isset($arr[$var])){if($arr[$var]==true){return true;}}return false;} function get_image_info($image,$field){ if($image==''){return '';} if(@getimagesize($image)) { $photo = getimagesize($image); if($field=='width'){return $photo[0];} if($field=='height'){return $photo[1];} if($field=='type'){return $photo['mime'];} } } function get_featured_image($post_id,$how=''){ if(has_post_thumbnail($post_id)){ $imgid = get_post_thumbnail_id($post_id); $img = wp_get_attachment_url($imgid); $imgdata = wp_get_attachment_metadata($imgid,true); $iwid = $this->get_value($imgdata,'width'); $ihit = $this->get_value($imgdata,'height'); if($iwid!=''){$imgwid = $iwid;} if($ihit!=''){$imgwid = $ihit;} if($how=='info'){return array('url'=>$img,'width'=>$iwid,'height'=>$ihit);} return $img; } return ''; } function set_featured_image($post_id, $attach_id){set_post_thumbnail( $post_id, $attach_id );} function round_to_decimal($number,$dec=1){$rat = ($dec*10);return round($number*$rat)/$rat;} function scrape_between($txt,$start,$end){ $splode = explode($start,$txt); $part = $this->get_value($splode,1); $parts = explode($end,$part); return $parts[0]; } function delimitit($str,$delim=',',$val=''){ if($str!=''){$str .= $delim;} $str .= $val; return $str; } function queryit($how,$table=NULL,$pass=NULL,$xtra=NULL){ // [NOTE] WHERE clauses must be passed as a string if query needs to go beyond the basic AND array, when passing a string for a WHERE clause, you must include everything beyond the table "WHERE ... ORDER BY... LIMIT..." // [NOTE] select - $pass can be an array or string and $xtra is left NULL or used to pass the ORDER BY and LIMIT clauses as text when using $pass as an array or separaten string // [NOTE] get - lookup a specific field: $pass = field name, $xtra = WHERE // [NOTE] update - normal update, will only update if found: $pass can be an array or string of updates, $xtra = WHERE // [NOTE] set - just like update, except it will insert if not found // [NOTE] insert - normal insert, it will insert duplicate content: $pass must be an array of inserts, $xtra is left NULL // [NOTE] put - same as insert, but only if not found: $xtra = WHERE // [NOTE] delete - $pass = WHERE, it must be an array, $xtra is left NULL // had to setup a bypass fucntion for this feature, it wasn't working correctly through the old system if($how=='set'){return $this->queryset($table,$pass,$xtra);} global $wpdb; if(is_string($how) and $table==NULL){return $this->object_to_array($wpdb->get_results($how));} $idt = 'ID'; if($table=='post' or $table=='posts'){ $table_name = $wpdb->prefix.'posts'; }else if($table=='meta'){ $idt = 'meta_id'; $table_name = $wpdb->prefix.'postmeta'; }else{ $idt = 'id'; $table_name = $this->get_table_name($table); } $fields = ''; if(is_array($how)){ if($table=='post' or $table=='posts'){ $fields = 'ID'; }else if($table=='meta'){ $fields = 'meta_id'; }else if(isset($this->self['custom_data_tables'][$table])){ $fields = 'id,pid'; } foreach($how as $field){ $fields = $this->delimitit($fields,',',$field); } $how = 'select'; } if($how=='get' or $how=='set' or $how=='put'){ if($pass!=NULL and $xtra!=NULL){ if(is_array($xtra)){ $where = ''; if(count($xtra)>0){ foreach($xtra as $k=>$v){ $where = $this->delimitit($where,' AND ',"`$k`='$v'"); } } if($where!=''){ $where = "WHERE ".$where; } $xtra = $where; } $qry = "SELECT * FROM $table_name $xtra"; $isthere = $this->object_to_array($wpdb->get_results($qry)); if($how=='set' or $how=='put'){ $isid = $this->get_value($isthere,array(0,'id')); if($isid!=''){ if($how=='put'){return false;} $how = 'update'; $xtra = "WHERE `id`='$isid' LIMIT 1"; }else{ $how = 'insert'; } }else if($how=='get'){ return $this->get_value($isthere,array(0,$pass)); } } } if($how=='select'){ if($pass==NULL){ $pass = ''; } $end = ''; if($xtra!=NULL and is_string($xtra)){ $end = $xtra; } $gets = '*'; if($fields!=''){$gets = $fields;} if(is_array($pass)){ $where = ''; if(count($pass)>0){ foreach($pass as $k=>$v){ $where = $this->delimitit($where,' AND ',"`$k`='$v'"); } } if($where!=''){ $where = "WHERE ".$where; } $qry = "SELECT $gets FROM $table_name $where $end"; }else{ $qry = "SELECT $gets FROM $table_name $pass $end"; } return $this->object_to_array($wpdb->get_results($qry)); }else{ if(is_array($pass)){ if($how=='update'){ if($xtra==NULL or $xtra==''){$xtra = "WHERE `$idt`>0";} if(is_string($xtra)){ $ups = ''; if(count($pass)>0){ foreach($pass as $k=>$v){ $ups = $this->delimitit($ups,',',"`$k`='$v'"); } } $qry = "UPDATE $table_name SET $ups $xtra"; return $this->object_to_array($wpdb->get_results($qry)); }else{ return $wpdb->update($table_name,$pass,$xtra); } }else if($how=='replace'){ return $wpdb->replace($table_name,$pass); }else if($how=='insert'){ return $wpdb->insert($table_name,$pass); }else if($how=='delete'){ return $wpdb->delete($table_name,$pass); } } } return NULL; } function validsql($input){ if(isset($input[0]['id']) or isset($input[0]['ID']) or isset($input[0]['meta_id'])){ return true; } return false; } function queryset($table,$data,$where){ $isit = $this->queryit('select',$table,$where); $id = $this->get_value($isit,array(0,'id')); if($id!=''){ $this->queryit('update',$table,$data,array('id'=>$id)); }else{ $this->queryit('insert',$table,$data); } } function register_cron($fct,$interval,$multiplier=1){ $intervals = array('minute'=>'minutely','hour'=>'hourly','halfday'=>'twicedaily','day'=>'daily','week'=>'weekly','month'=>'monthly','3hours'=>'3hours','6hours'=>'6hours','5minutes'=>'5minutes'); $itype = ''; if(isset($intervals[$interval])){ $itype = $intervals[$interval]; }else{ foreach($intervals as $k=>$v){ if($interval==$v){ $itype = $v; } } } if($itype!=''){ $this->self['cron_list'][$fct] = $itype; } } function has_cron(){if(isset($this->self['cron_list'])){if(count($this->self['cron_list'])>0){return true;}}return false;} function custom_cron_schedules( $schedules ) { $arr = array(); if($this->has_cron()){ foreach($this->self['cron_list'] as $fct=>$type){ $arr[$type] = true; } } if(isset($arr['minutely'])){$schedules['minutely'] = array('interval' => 60,'display' => 'Every Minute');} if(isset($arr['weekly'])){$schedules['weekly'] = array('interval' => 60480,'display' => 'Every Week');} if(isset($arr['monthly'])){$schedules['monthly'] = array('interval' => 259200,'display' => 'Every 30 Days');} if(isset($arr['3hours'])){$schedules['3hours'] = array('interval' => 1080,'display' => 'Every 3 Hours');} if(isset($arr['6hours'])){$schedules['6hours'] = array('interval' => 2160,'display' => 'Every 6 Hours');} if(isset($arr['5minutes'])){$schedules['5minutes'] = array('interval' => 300,'display' => 'Every 5 Minutes');} return $schedules; } function get_cron($fct){return wp_next_scheduled($fct.'_cron');} function clear_cron($fct){wp_clear_scheduled_hook($fct.'_cron');} function cancel_cron($fct){ $action = $fct.'_cron'; $next = wp_next_scheduled($action); wp_unschedule_event( $next, $action); } function ajax_communication(){ $command = $this->get_value($_POST,'command'); if(method_exists($this,$command)){ $this->runit($command,$_POST); } } function add_action($act,$bct=''){ if($bct!=''){ if(is_array($bct)){ $fct = $bct; }else{ $fct = $this->get_action($bct); } }else{ $fct = $this->get_action($act); } if($fct!=''){ if($act=='save_post'){ add_action($act,$fct,10,2); }else{ add_action($act,$fct); } } } function get_action($fct){ if(function_exists($this->self['prefix'].'_'.$fct)){ //echo "FUNCTION EXISTS"; return $this->self['prefix'].'_'.$fct; }else if(method_exists($this,$fct)){ //echo "METHOD EXISTS"; return array(&$this,$fct); }else{ //echo "NOT FOUND"; return ''; } } function validate_url($string) { if(filter_var($string, FILTER_VALIDATE_URL)){return true;} return false; } function is_image($string){ $info = pathinfo($string); if(isset($info['extension'])){ return in_array(strtolower($info['extension']),array("jpg", "jpeg", "gif", "png", "bmp")); } return false; } // DEBUGGING FUNCTIONS function debug_mode(){$this->self['DEBUG_MODE_STATE'] = true;} function debugging(){ if(isset($this->self['DEBUG_MODE_STATE'])){ if($this->self['DEBUG_MODE_STATE']==true){ return true; } } return false; } function debug($txt,$pass,$line='
',$how='echo'){ if($this->debugging()==false){return '';} $txt = strtoupper($txt); if(is_string($pass)){ $str = 'DEBUG: ['.$txt.'] = '.$pass.$line; if($how=='echo'){ echo $str; }else{ return $str; } }else if(is_array($pass) or is_object($pass)){ if($how=='echo'){ echo $this->function_call_info('DEBUG: ['.$txt.']'); $this->test_array($pass); }else{ $RAT = ''; $RAT .= $this->function_call_info('DEBUG: ['.$txt.']'); $RAT .= $this->test_array($pass,''); return $RAT; } } } function function_call_info($fct='',$params=array()){ // SIMPLE FUNCTION USED DURING TESTING FOR HILIGHTING WHEN A FUNCTION CALL IS ADDED TO THE OUTPUT // [TASK: it would be nice to be able to gather function call info when any functin is called during debug mode] if($this->debugging()==false){return '';} $RAT = ''; $keys = ''; if(count($params)>0){ foreach($params as $k=>$v){ if($keys!=''){$keys.=',';} if(!is_numeric($k)){ $keys .= $k.'=>'; } $keys .= $v; } } $RAT .= '
'; $RAT .= 'FUNCTION CALL: '.$fct.'('.$keys.')'; $RAT .= '
'; return $RAT; } function test_array($arr=array(),$how='echo',$px=0){ if($this->debugging()==false){return '';} if(is_string($arr)){ if($how=='echo'){ echo $arr; } return $arr; } if(is_object($arr)){$arr = $this->object_to_array($arr);} $RAT = ''; if(is_array($arr)){ if(count($arr)>0){ foreach($arr as $k=>$v){ if(is_array($v) or is_object($v)){ if($how=='echo'){ if($how=='js'){ echo $k.' = '; }else{ echo '
['.$k.'] '; } $this->test_array($v,$how,$px+20); if($how!='js'){echo '
';} }else{ if($how=='js'){ echo $k.' = '; }else{ $RAT .= '
['.$k.'] '; } $RAT .= $this->test_array($v,$how,$px+20); if($how!='js'){$RAT .= '
';} } }else{ if($how=='js'){ $div = $k.' = '.$v.'\n'; }else if($how=='raw'){ $div = '['.$k.']'.$v; }else{ $div = '
['.$k.'] '.$v.'
'; } if($how=='echo'){ echo $div; }else{ $RAT .= $div; } } } } } return $RAT; } function trim_decimals($floatin,$decs=0){ $mult = 1; for($dd=1;$dd<=$decs;$dd++){ $mult *= 10; } $floater = (int)($floatin*$mult); return $floater/$mult; } function microtime_float(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function start_timer($timer="default"){ if($this->debugging()==false){return '';} global $phpscripttimer; if(!isset($phpscripttimer)){ $phpscripttimer = array(); } $phpscripttimer["$timer"] = $this->microtime_float(); } function end_timer($timer="default",$report=true){ if($this->debugging()==false){return '';} global $phpscripttimer; if(isset($phpscripttimer["$timer"])){ $now = $this->microtime_float(); $secs = $this->trim_decimals(($now-$phpscripttimer["$timer"]),4); if($report==true){ return "SCRIPT TIMER ($timer): $secs seconds"; }else{ return $secs; } }else{ return "NO TIMER INITIATED"; } } function domain_from_url($url=NULL){ if($url==NULL){$url = $this->current_page_url();} $dats = parse_url($url); return $dats['host']; } function object_to_array($d){if(is_object($d)){$d = get_object_vars($d);}if(is_array($d)){return array_map(array($this,'object_to_array'),$d);}else{return $d;}} function get_site_base_url(){return esc_url(home_url());} function get_site_template_url(){return esc_url(get_template_directory_uri());} function theme_page_title($post_id=NULL){ if(is_category()){single_cat_title();} elseif(is_tag()){single_tag_title();} elseif(is_author()){global $post;$author_id = $post->post_author;the_author_meta('display_name', $author_id);} elseif(is_day()){the_time('l, F j, Y');} elseif(is_month()){the_time('F Y');} elseif(is_year()){the_time('Y');} elseif(is_single() or is_page()){the_title();} } function ucwords_undash($input){return ucwords(str_replace('-',' ',$input));} function extends_init(){ $this->self['apibaseurl'] = 'http://ampwptools.com'; if(class_exists('wfConfig')){ $wfwall = wfConfig::get('ajaxWatcherDisabled_front'); if(!$wfwall){ $wferr = 'Wordfence Firewall is active on the "Front" end, the javascript file it loads will cause Google AMP Validation to fail.
You can turn this setting off in: wp-admin ~ Wordfence ~ Firewall ~ uncheck "Front" under "Monitor Background Requests for False Positives:"
AMP does not need to validate while logged in, so you may leave "Admin Panel" checked.'; $this->register_notice($wferr,'warning'); } } $this->filter_handler('body_class'); $this->filter_handler('comment_post_redirect'); $this->filter_handler('comment_reply_link',30,4); $this->filter_handler('get_avatar',10,5); $this->filter_handler('language_attributes',9999); $this->filter_handler('login_headertitle'); $this->filter_handler('login_headerurl'); $this->filter_handler('mce_buttons_2'); $this->filter_handler('post_thumbnail_html'); $this->filter_handler('pre_get_document_title'); $this->filter_handler('show_admin_bar'); $this->filter_handler('the_content'); $this->filter_handler('tiny_mce_before_init',9); //$this->filter_handler('widget_text',30,1);// work in progress } function is_amp_search(){return true;} function is_advanced(){ if(function_exists('tacg_adv')){return true;} return false; } function ajax_amp_preview($params){// started from generate_live_editor() $wid = $this->get_value($params,'width','100%'); $hit = $this->get_value($params,'height','600px'); $how = $this->get_value($params,'how'); $url = $this->get_value($params,'url'); $adds = $this->get_value($params,'adds'); $urls = explode('?',$url); $url = $urls[0]; echo '
'; $ashow = ''; if(how!=''){$ashow = 'as'.$how;} echo '
'; echo '
'; echo '';// iframe for preview only echo '
'; echo '
'; } function ajax_buttonbar_update($params){ $list = $this->get_value($params,'list'); set_theme_mod('social_buttonlist',$list); } function ajax_choose_fontawesome($params){ $where = $this->get_value($params,'where'); $jst = 'html_editor'; if($where=='buttonbar'){$jst = 'buttonbar';} $icons = $this->get_fontawesome_icons(); echo '
'; echo '

Select an Icon

'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; if(count($icons)>0){ foreach($icons as $icon){ echo '
'; echo ''; echo '
'; } }else{ echo 'Unable to access the Font Awesome Library at this moment.'; } echo '
'; echo '
'; } function ajax_content_editor($params){ $RAT = ''; $btnid = $this->get_value($params,'id'); $type = $this->get_value($params,'pagetype'); $post_id = $this->get_value($params,'postid'); $term_id = $this->get_value($params,'termid'); if($type=='category'){ $id = 'archive-title'; $val = $this->get_category_title($term_id); $pageid = $term_id; }else{ $id = 'pageorpost-title'; $val = $this->get_page_title($post_id); $pageid = $post_id; } if($post_id==0 and $term_id==0){ $lctxt = 'The Live Composer is available'; if($this->is_advanced()){$lctxt = 'Some page options are available';} $RAT .= '
This is the WP Default Home Page
'; $RAT .= '
This default Wordpress blog posts page displays your latest posts using settings found in WP-Admin ~ Settings ~ Reading.

If you wish to edit your home page content, go to Reading and assign a page to act as your Fron Page.
'; $RAT .= '
Current Page Options
'; }else{ if($type=='category'){ $RAT .= 'Category Description Editor'; }else{ $RAT .= 'Page Content HTML Editor'; } $RAT .= '
Current Page Options
'; $RAT .= $this->editor_node($id,array('type'=>'text','value'=>$val,'flag'=>'temp','onedit'=>"tacg_live_pagetitle_edit('".$id."','[[VALUE]]');"),'Page Name/Title','datanode'); $RAT .= '
Your changes have been saved but a browser refresh is required to view all potential changes.
'; if($type=='post'){ $featured = $this->get_page_setting($pageid,$type,'featured'); $RAT .= $this->editor_node('featured',array('type'=>'checkbox','value'=>$featured,'flag'=>'temp','class'=>'tclass','onedit'=>"tacg_live_setting('featured','[[VALUE]]');"),'Set as Featured Post','datanode'); } $hideside = $this->get_page_setting($pageid,$type,'hidesidebar'); $RAT .= $this->editor_node('hidesidebar',array('type'=>'checkbox','value'=>$hideside,'flag'=>'temp','class'=>'tclass','onedit'=>"tacg_live_setting('hidesidebar','[[VALUE]]');"),'Hide Sidebar on this Page','datanode'); } $RAT .= '
'; if(defined('WPSEO_FILE')){ $RAT .= '
The title tag and meta description are handled by the Yoast SEO plugin. You may edit them here when that plugin is deactivated.
'; }else{ $metatitle = $this->get_page_setting($pageid,$type,'metatitle'); $RAT .= $this->editor_node('page_metatitle',array('type'=>'text','value'=>$metatitle,'onedit'=>"tacg_live_setting('metatitle','[[VALUE]]');"),'Meta Title','datanode'); $metadesc = $this->get_page_setting($pageid,$type,'metadesc'); $RAT .= $this->editor_node('page_metadesc',array('type'=>'textarea','value'=>$metadesc,'onedit'=>"tacg_live_setting('metadesc','[[VALUE]]');"),'Meta Description','datanode'); } echo $RAT; } function ajax_get_dat($params){ $id = $this->get_value($params,'id'); $content = ''; if($id=='pageorpost-content'){ $post_id = $this->get_value($params,'postid'); $content_post = get_post($post_id); $content = $content_post->post_content; $content = str_replace(']]>', ']]>', $content); $content = $this->htmlout($content); }else if($id=='pageorpost-title'){ $post_id = $this->get_value($params,'postid'); $content_post = get_post($post_id); $content = $content_post->post_title; }else if($id=='archive-content'){ $term_id = $this->get_value($params,'termid'); $term = get_term($term_id,'category'); $desc = $term->description; $content = $this->theme_content_filter($desc); }else if($id=='archive-title'){ $term_id = $this->get_value($params,'termid'); $term = get_term($term_id,'category'); $content = $term->name; }else{ $content = $this->get_dat($id); } $content = $this->htmlout($content); $content = stripslashes($content); if($this->get_value($params,'ret')=='gen'){ return $content; }else{ die($content); } } function ajax_live_editor($params){ $text = $this->get_value($params,'txt'); $nodes = $this->get_value($params,'nodes'); if($nodes==''){ $id = $this->get_value($params,'id'); $type = $this->get_value($params,'typ'); $mod = $this->get_value($params,'mod'); $text = $this->get_value($params,'txt'); $txt = $this->htmlout($text); $txt = stripslashes($txt); $slug = $this->get_value($params,'slug'); $post_id = $this->get_value($params,'postid'); if($id=='pageorpost-content'){ $my_post = array('ID'=>$post_id,'post_content'=>$txt); wp_update_post( $my_post ); echo $this->content_filter($txt); }elseif($id=='pageorpost-title'){ $my_post = array('ID'=>$post_id,'post_title'=>$txt); wp_update_post($my_post); }elseif($id=='archive-content'){ $term_id = $this->get_value($params,'termid'); wp_update_term($term_id, 'category', array('description'=>$txt)); echo $this->content_filter($txt); }elseif($id=='archive-title'){ echo $txt; $term_id = $this->get_value($params,'termid'); wp_update_term($term_id, 'category', array('name'=>$txt)); }elseif($id=='testtext'){ $txt = $this->htmlin($txt); $this->save_dat('testtext',$txt); echo $this->content_filter($txt); }elseif($type=='text'){ set_theme_mod($mod,$txt); echo $this->content_filter($txt); }elseif(type=='dat'){ $this->save_dat($id,$txt); }elseif($type=='color'){ set_theme_mod($mod,$txt); }elseif($type=='setting'){ $pageid = $post_id; $pagetype = $this->get_value($params,'pagetype'); if($pagetype=='category'){ $pageid = $this->get_value($params,'termid'); } $this->set_page_setting($pageid,$pagetype,$id,$txt); } }else{ $arr = explode(',',$nodes); if(count($arr)>0){ foreach($arr as $node){ $val = $this->get_value($params,$node); if(substr($node,0,11)!='editoption_'){ if($node=='page_title'){ $post_id = $this->get_value($params,'postid'); $my_post = array('ID'=>$post_id,'post_title'=>$val); wp_update_post($my_post); continue; } $data = $this->get_customizer_settings($node); $type = $this->get_value($data,'type'); if($type=='image'){ $add = $this->get_value($params,'editoption_addmedia'); if($val==''){ $url = ''; }else{ if($this->UR_exists($val)){ $url = $val; } // WPFIX //else{ // $url = $this->create_image_file($node,$val,$add); //} } set_theme_mod($node,$url); }else{ $val = stripslashes($val); $val = $this->htmlin($val); set_theme_mod($node,$val); } } } } } } function ajax_load_editor($params){ $id = $this->get_value($params,'id'); $type = $this->get_value($params,'typ'); $local = $this->get_value($params,'local'); global $tacgfct; $theme = $this->get_customizer_setting('site_layout'); $textnotice = '
Some settings will require a browser refresh to view all potential changes.
'; if($type=='editor'){ if($id=='sitewide_editor'){ echo $this->generate_editor_header('Sitewide',$local); echo '
General Layout
'; echo $this->editor_node('site_layout'); //echo $this->editor_node('site_rounded'); echo $this->editor_node('site_wrapconstrain'); echo '
Sidebar Visibility
'; echo '
'; echo $this->editor_node('site_hidehomesidebar','refresh'); echo $this->editor_node('site_hidepagesidebar','refresh'); echo $this->editor_node('site_hidepostsidebar','refresh'); echo $this->editor_node('site_hidecategorysidebar','refresh'); echo $textnotice; echo '
'; if(!$this->is_advanced()){ echo $this->generate_icon_button(array('label'=>'Restore Sitewide Defaults','title'=>'Restore all sitewide styles and settings to the default.','icon'=>'recycle','click'=>'tacg_restore_defaults();','style'=>'width:100%;margin-top:5px;')); } echo ''; }else if($id=='sitewide_style'){ echo $this->generate_editor_header('Sitewide',$local); echo '
Font Styling
'; echo $this->editor_node('site_fontsize'); echo $this->editor_node('site_h1fontsize'); echo $this->editor_node('site_h2fontsize'); echo $this->editor_node('site_h3fontsize'); echo '
'; echo $textnotice; echo $this->editor_node('site_fontcolor','refresh'); echo $this->editor_node('site_linkcolor','refresh'); echo $this->editor_node('site_linkhovercolor','refresh'); echo '
'; echo '
Background Color / Image
'; echo $this->editor_node('site_bgcolor'); echo $this->editor_node('site_bgimage'); echo $this->editor_node('site_bgimagerepeat'); echo '
Posts / Archives Display
'; echo $this->editor_node('site_postsdisplaymode'); echo $this->editor_node('site_postsdisplayheight'); echo $this->editor_node('site_hidebyline'); echo '
The Flags you see (category/tag) in Posts "Article" Display Mode use the site\'s link colors by default, but you may choose custom styling for them here. Clear the color assignment to again use the link colors. You must refresh the browser to view changes to the flags.
'; echo '
'; echo $this->editor_node('site_postagfcolor','refresh'); echo $this->editor_node('site_postagcolor','refresh'); echo $this->editor_node('site_postaghcolor','refresh'); echo '
'; echo '
Default Image
'; echo '
When an image is needed but none is assigned, the theme uses a default image labeled "no available photo". You may assign your own default image in it\'s place.
'; echo '
'; echo $this->editor_node('site_defaultimage','refresh'); echo '
'; if($this->is_advanced()){ echo '
Title Block Modules
'; echo '
You insert Title Block Modules with the Composer wherever you wish. You decide here which style and colors they use.
'; echo $this->editor_node('site_tbkdisplay'); echo $this->editor_node('site_tbkcolor'); echo '
'; echo $this->editor_node('site_tbkbgcolor','refresh'); echo '
'; } echo ''; }else if($id=='banner'){ echo $this->generate_editor_header('Header',$local); echo $this->editor_node('header_hidebanner'); echo $this->editor_node('header_vpad'); //echo $this->editor_node('header_lhpad'); echo $this->editor_node('header_bgcolor'); echo $this->editor_node('header_logoimage'); echo $this->editor_node('header_bgimage'); echo $this->editor_node('header_bgimagerepeat'); echo '
Cassic Layout
'; echo '
Options used only in the Classic Layout.
'; echo $this->editor_node('header_txtcolor'); echo $this->editor_node('header_hide_blogname'); echo $this->editor_node('header_hide_blogdesc'); echo ''; }else if($id=='titlebar'){ echo $this->generate_editor_header('Header',$local); echo '
Title & Tagline sizes are determined by your sitewide H1 & H2 settings (respectively).
The Classic Layout hides the Title Bar, the page title is inserted near the page content.
'; echo $this->editor_node('header_hidetitlebar'); echo $this->editor_node('header_tbartxtcolor'); echo $this->editor_node('header_tbarbgcolor'); echo $this->editor_node('header_tbarvpad'); echo ''; }else if($id=='sub-header'){ echo $this->generate_editor_header('Sub-Header',$local); //echo $this->editor_node('subheader_mobiletransform'); echo $this->editor_node('navmenu_menufontsize'); echo $this->editor_node('navmenu_menucase'); echo $this->editor_node('subheader_bgcolor'); echo $this->editor_node('subheader_txtcolor'); echo '
'; echo $this->editor_node('subheader_menuhovertext'); echo $this->editor_node('subheader_hidesearch'); echo '
'; echo $textnotice; echo '
Hover-Drop Menu
'; echo '
'; echo $this->editor_node('navmenu_submenutext'); echo $this->editor_node('navmenu_submenubg'); echo $this->editor_node('navmenu_submenuhovertext'); echo $this->editor_node('navmenu_submenuhoverbg'); echo $this->editor_node('navmenu_submenuborder'); echo '
'; echo $this->editor_node('navmenu_submenuborderhide'); echo '
Slideout Mobile Menu
'; echo '
The Mobile Menu is opened using the "Hamburger" button that appears in devices and small browser windows. The button is always visible in the Side Navigation Layout.
'; echo '
'; echo $this->editor_node('mobilemenu_block'); echo '
'; echo ''; }else if($id=='social_editor'){ echo $this->generate_editor_header('Social',$local); echo '
Button Manager
'; echo $this->editor_node('social_buttonlist'); echo $this->generate_social_button_manager(); echo '
Some icons will look odd if your choose the Circle or Square styles. Look for icons that are close in width and height.
'; echo '
Header Button Styling
'; echo $this->editor_node('header_hidesocial'); echo $this->editor_node('social_rssfeed'); echo $this->editor_node('social_headerstyle'); echo $this->editor_node('social_iconcolor'); echo $this->editor_node('social_iconhovercolor'); echo $this->editor_node('social_bordercolor'); echo '
Footer Button Styling
'; echo $this->editor_node('footer_hidesocial'); echo $this->editor_node('social_footerbarcolor'); echo $this->editor_node('social_footerstyle'); echo $this->editor_node('social_footersize'); echo $this->editor_node('social_footericoncolor'); echo $this->editor_node('social_footericonhovercolor'); echo $this->editor_node('social_footerbordercolor'); echo ''; }else if($id=='footer'){ echo $this->generate_editor_header('Footer',$local); echo $this->editor_node('footer_copyrighttext'); echo $this->editor_node('footer_textcolor'); echo $this->editor_node('footer_bgcolor'); echo $this->editor_node('footer_menutext'); echo '
'; echo $this->editor_node('footer_menuhovertext'); echo '
'; echo $textnotice; echo ''; }else if($id=='seo'){ echo $this->generate_editor_header('SEO Enhancements',$local); echo $this->editor_node('seo_inlinemarkup'); echo '
Breadcrumbs
'; echo '
When you have Yoast SEO activated and "Enable Breadcrumbs" enabled, the breadcrumbs are instead generated by that plugin.
'; echo $this->editor_node('seo_breadcrumbhide'); echo $this->editor_node('seo_boldlast'); echo $this->editor_node('seo_breadcrumbsep'); echo ''; }else{ if($this->is_advanced()){$this->adv_load_editor($params);} } } } function ajax_mobile_menu_block($params){echo $this->generate_mobile_menu_block($params);} function ajax_restore_defaults($params){ if(isset($this->self['customizer_settings'])){ foreach($this->self['customizer_settings'] as $setting=>$data){remove_theme_mod($setting);} } } function amp_filter($content){ $content = $this->amp_styles_to_classes($content); $content = preg_replace('!style="(.*?)"!s','',$content); $content = preg_replace('!!s','',$content);// remove injected iframes from content $content = preg_replace("@()@i", "$1",$content); $content = str_replace('/>','>',$content); $content = str_replace('','',$content); return $content; } function amp_style_replacements(){ $replacements = array(); $replacements['text-align'] = 'align'; $replacements['text-decoration'] = 'deco-'; $replacements['font-size'] = 'fsize-'; $replacements['font-weight'] = 'fwgt-'; $replacements['font-family'] = 'ffam-'; $replacements['color'] = 'clr-'; $replacements['background-color'] = 'bgclr-'; $replacements['margin'] = 'marg-'; $replacements['margin-top'] = 'margt-'; $replacements['margin-right'] = 'margr-'; $replacements['margin-bottom'] = 'margb-'; $replacements['margin-left'] = 'margl-'; $replacements['padding'] = 'padd-'; $replacements['padding-top'] = 'padt-'; $replacements['padding-right'] = 'padr-'; $replacements['padding-bottom'] = 'padb-'; $replacements['padding-left'] = 'padl-'; return $replacements; } function amp_styles_css($k,$v){ $v = trim($v); $v = str_replace('#','',$v); $vc = $v; $va = $v; if($k=='font-family'){ $vc = str_replace(',','-',$vc); $va = str_replace('-',',',$va); } $vc = str_replace(' ','_',$vc); $va = str_replace('_',' ',$va); $val = ''; $replacements = $this->amp_style_replacements(); $rv = $this->get_value($replacements,$k); if($rv!=''){ $ck = ''; if($k=='color' or $k=='background-color'){$ck = '#';} $val = '.'.$rv.$vc.'{'.$k.':'.$ck.$va.';}'; } return $val; } function amp_styles_to_classes($in,$ask=''){ $replacements = $this->amp_style_replacements(); $handler = array(); $out = $in; $RAT = ''; $arr = explode('<',$in); foreach($arr as $arp){ $brr = explode('>',$arp); $tag = $brr[0]; if(strstr($tag,'style="')){ $styles = array(); $style = $this->scrape_between($tag,'style="','"'); $classes = ''; $parts = explode(';',$style); if(count($parts)>0){ foreach($parts as $part){ $prt = trim($part); $keys = explode(':',$prt); $key = $keys[0]; $val = trim($this->get_value($keys,1)); if(isset($replacements[$key])){ $styles[$key] = $val; $handler[] = $styles; } } foreach($styles as $k=>$v){ $vcon = $replacements[$k]; $vc = trim($v); if($k=='font-family'){$vc = str_replace(',','-',$vc);} $vc = str_replace(' ','_',$vc); $vc = str_replace('#','',$vc); $vcon .= $vc; $classes = $this->delimitit($classes,' ',$vcon); } } if(strstr($tag,'class="')){ $scrap = $this->scrape_between($tag,'class="','"'); if($scrap!=''){$classes = $this->delimitit($classes,' ',$scrap);} } $newtag = preg_replace('!style="(.*?)"!s','',$tag); $newtag = preg_replace('!class="(.*?)"!s','',$newtag); if(substr($newtag,-1,1)=='/'){ $bstr = substr($newtag,0,-1); $newtag = $bstr.' class="'.$classes.'" /'; }else{ $newtag .= ' class="'.$classes.'"'; } $newtag = '<'.trim($newtag).'>'; $oldtag = '<'.$tag.'>'; $out = str_replace($oldtag,$newtag,$out); } } if($ask=='styles'){return $handler;} return $out; } function amp_video_from_shortcode($txt){ $exp = explode('[video ',$txt); foreach($exp as $part){ $video = $this->scrape_between('[SS]'.$part,'[SS]','][/video]'); $find = '[video '.$video.'][/video]'; $vex = 'video='; $vid = str_replace(array('mp4=', 'm4v=', 'webm=', 'ogv=', 'wmv=', 'flv='),array($vex,$vex,$vex,$vex,$vex,$vex),$video); $rep = '[video provider="video" '.$vid.']'; $txt = str_replace($find,$rep,$txt); } return $txt; } function content_filter($content,$ampd=false){ $content = preg_replace("/\r\n|\r|\n/",'
',$content); if($ampd==true){$content = $this->amp_filter($content);} //$content = str_replace('
','
',$content);// attempt for HTML5 compliance, all tries only made it worse $content = $this->amp_video_from_shortcode($content); $content = $this->theme_content_filter($content); return $content; } function editor_node($id,$type=NULL,$label=NULL,$class='datanode',$desc=NULL){ $RAT = ''; $val = $def = $oe = $oc = ''; if(is_array($type)){ $data = $type; $type = NULL; $def = $this->get_value($data,'default'); $val = $this->get_value($data,'value'); $val = $this->htmlout($val); }else{ $data = $this->get_customizer_settings($id); $def = $this->get_value($data,'default'); $val = $this->get_customizer_setting($id); $val = $this->htmlout($val); } $filter = $this->get_value($data,'filter'); $flag = $this->get_value($data,'flag'); $oe = $this->get_value($data,'onedit'); $oc = $this->get_value($data,'onclear'); $refresh = false; if($type=='refresh'){$refresh = true;$type = NULL;} $onsave = ''; if($refresh==true){$onsave = 'refresh';} if($type==NULL){$type = $this->get_value($data,'type');} if($label==NULL){$label = $this->get_value($data,'title');} if($desc==NULL){$desc = $this->get_value($data,'description');} if($val==''){$val = $def;} $tval = $val;if($type=='textarea'){$tval = $this->htmlin($val);} $RAT .= ''; $RAT .= ''; $disp = 'block';if($id=='editoption_addmedia' or $type=='hidden'){$disp = 'none';} $RAT .= '
'; if($type!='hidden'){ if($type=='color'){$RAT .= $this->generate_live_color_picker($id,$val,$label);} $RAT .= ''; if($type=='image'){$RAT .= $this->generate_browser_zone($id,$val,$label);} if($type=='checkbox'){$RAT .= $this->generate_live_checkbox($id,$val,$flag);} if($type=='text'){$RAT .= $this->generate_live_textfield($id,$val,$filter,$flag);} //if($type=='hidden'){$RAT .= $this->generate_live_textfield($id,$val,$filter,$flag,true);} if($type=='textarea'){$RAT .= $this->generate_live_textarea($id,$val,$flag);} if($type=='select'){ $opts = $this->get_value($data,'choices'); $RAT .= $this->generate_live_select($id,$val,$opts,$flag); } if($type=='html'){$RAT .= 'Open HTML Editor';} $RAT .= ''; if($type!='image'){ $RAT .= ''; if($desc!=''){ $RAT .= '
'.$desc.'
'; } } } $RAT .= '
'; return $RAT; } function filter_handler($pass,$prio=10,$accs=1){add_filter($pass,array(&$this,'wp_'.$pass),$prio,$accs);} function generate_amp_markups(){ $data = $this->get_document_data(); $pageid = $this->get_value($data,'pageid'); $pagetype = $this->get_value($data,'pagetype'); $jsontype = $this->get_value($data,'jsontype'); $url = $this->get_value($data,'url'); $headline = $this->get_value($data,'headline'); $desc = $this->get_value($data,'desc'); $contype = $this->get_value($data,'contype'); $title = $this->get_value($data,'title'); $sitename = $this->get_value($data,'sitename'); $published = $this->get_value($data,'published'); $modified = $this->get_value($data,'modified'); $author = $this->get_value($data,'author'); $authorid = $this->get_value($data,'authorid'); $publisher = $this->get_value($data,'publisher'); $publishertype = $this->get_value($data,'publishertype'); $logo = $this->get_value($data,'logo'); $logow = $this->get_value($data,'logow'); $logoh = $this->get_value($data,'logoh'); $img = $this->get_value($data,'img'); $imgw = $this->get_value($data,'imgw'); $imgh = $this->get_value($data,'imgh'); $images = $this->get_value($data,'',array()); $category = $this->get_value($data,'category'); $RAT = ''; // Yoast SEO integration, use yoast if installed and option is turned on $useog = true; $usetwit = true; $yoast = false; $yoasted = false; if(defined('WPSEO_FILE')){ $yoast = true; $options = WPSEO_Options::get_option('wpseo_social'); if($options['opengraph']===true){$useog = false;} if($options['twitter']===true){$usetwit = false;} } if(is_home() or is_front_page()){if($yoast==true){$yoasted = true;}} if($useog==true){ $RAT .= ''; $RAT .= ''; $RAT .= ''; $RAT .= ''; $RAT .= ''; if($img!=''){$RAT .= '';} if(count($images)>0){ foreach($images as $image){ $RAT .= ''; } } } if($usetwit==true){ $RAT .= ''; $RAT .= ''; if($img!=''){$RAT .= '';} } if(is_single()){ if($category!=''){$RAT .= '';} if($published!=''){$RAT .= '';} if($modified!=''){ $RAT .= ''; $RAT .= ''; } } if($logo==''){ $logo = $this->get_default_image(); $logow = $this->get_image_info($logo,'width'); $logoh = $this->get_image_info($logo,'height'); } if($img==''){$img = $logo;$imgw = $logow;$imgh = $logoh;} $RAT .= ''; return $RAT; } function generate_amp_preview_link($pass=''){ if($pass!=''){$pass = ' '.$pass;} return ' open this page in AMP Development Mode'.$pass.''; } function generate_amp_search_form($how='',$hwid=''){ $sval = $this->get_value($_GET,'s'); $RAT = ''; $RAT .= '
'; $RAT .= '
'; $RAT .= ''; $RAT .= ''; $RAT .= 'Search'; $RAT .= ''; $RAT .= '
'; $RAT .= '
'; return $RAT; } function generate_browser_zone($id,$val='',$label='Image Preview'){ $RAT = ''; $RAT .= '
'; $RAT .= '
'.$label.'
'; if($val==''){$val = $this->self['PATH'].'images/chooseimage.png';} $RAT .= ''; $RAT .= ''; $RAT .= '
Click to Browse Media Library
'; $RAT .= '
'; $RAT .= '
'; $RAT .= '
'; return $RAT; } // WPTASK - THIS NEEDS OVERHAUL FOR SEPARATION BETWEEN THEME AND PLUGIN function generate_compiled_css($ampd,$pageid,$pagetype){ $RAT = ''; if($ampd){ $layout = $this->get_customizer_setting('site_layout'); if($layout==''){$layout = 'base';} $RAT .= $this->function_call('generate_css_layout_'.$layout); $cssfiles = array(); $display = $this->get_customizer_setting('site_postsdisplaymode'); $cssfiles = $this->process_css_for_display($cssfiles,$display); if($this->is_advanced()){$cssfiles = $this->adv_compiled_css($cssfiles,$ampd,$pageid,$pagetype);} if(count($cssfiles)>0){foreach($cssfiles as $file){$RAT .= $this->function_call('generate_css_'.$file);}} }else{ $arr = $this->get_customizer_settings('site_layout'); $layouts = $this->get_value($arr,'choices'); if($layouts!=''){foreach($layouts as $layout=>$layttl){$RAT .= $this->function_call('generate_css_layout_'.$layout);}} $displays = array('article','image','onethree','thumbnail'); foreach($displays as $display){$RAT .= $this->function_call('generate_css_display_'.$display);} $modules = array('social_share','accordion','carousel'); foreach($modules as $mod){$RAT .= $this->function_call('generate_css_module_'.$mod);} } return $RAT; } function generate_custom_css(){ $RAT = ''; // start a stack of styles to be managed - preventing redundancy $stack = array(); if($this->is_advanced()){ $RAT .= $this->generate_composer_css(); //$stack = $this->generate_composer_stack($stack); } // gather styles onto the stack for Page/Post/Category Content conversions //if($params==NULL){ $data = $this->get_document_data(); $pagetype = $this->get_value($data,'pagetype'); if($pagetype=='category'){ $content = $this->ajax_get_dat(array('id'=>'archive-content','ret'=>'gen')); }else{ $content = $this->ajax_get_dat(array('id'=>'pageorpost-content','ret'=>'gen')); } $styles = $this->amp_styles_to_classes($content,'styles'); if(count($styles)>0){ foreach($styles as $style){ foreach($style as $k=>$v){ $val = $this->amp_styles_css($k,$v); if($val!=''){if(!isset($stack[$val])){$stack[$val] = $val;}} } } } //} // check for banner logo, get width, then setup css media override to responsive when the image is wider than the viewport... only way to bypass the AMP manipulations that I've found so far $logo = $this->get_customizer_setting('header_logoimage'); if($logo!=''){ $imgdata = $this->get_attachment_id_by_src($logo); $wid = $this->get_value($imgdata,'width'); $hit = $this->get_value($imgdata,'height'); $stack[] = '@media (max-width:'.$wid.'px){.headerlogo{position:unset;}.headerlogo img{height:unset;}}'; } // add social network colors for use in buttons and links $socs = $this->get_social_network_data('social'); foreach($socs as $soc=>$data){ $color = $this->get_value($data,'color'); $stack[] = '.clr-'.$soc.',a.clr-'.$soc.'{color:'.$color.';}'; $stack[] = '.bgclr-'.$soc.'{background-color:'.$color.';}'; } // process stack into CSS if(count($stack)>0){foreach($stack as $css){$RAT .= $css;}} return $RAT; } function generate_editor_header($title,$how=''){ $RAT = ''; $RAT .= '
'; return $RAT; } function generate_icon_button($params){ $label = $this->get_value($params,'label'); $title = $this->get_value($params,'title'); $icon = $this->get_value($params,'icon'); $size = $this->get_value($params,'size'); $class = $this->get_value($params,'class'); $style = $this->get_value($params,'style'); $click = $this->get_value($params,'click'); $stize = '';if($size!=''){$stize = ' style="font-size:'.$size.'px;"';} $cls = 'icnbtn';if($class!=''){$cls .= ' '.$class;} $ttl = '';if($title!=''){$ttl = 'title="'.$title.'"';} $RAT = ''; $RAT .= ''; if($icon!=''){$RAT .= '';} if($label!=''){$RAT .= ''.$label.'';} $RAT .= ''; return $RAT; } function generate_live_checkbox($id,$val,$flag=''){ $chk = ''; if($val=='1' or $val=='true' or $val===true){$chk = ' checked';} return ''; } function generate_live_color_picker($id,$val,$ttl=''){ $RAT = ''; $rgb = ''; $hex = ''; if($this->isRGB($val)){$hex = $this->rgbToHex($val);$rgb = $this->rgbToArray($val);} if($this->isHex($val)){$rgb = $this->hexToRGB($val);$hex = $val;} $RAT .= '
'; $RAT .= '
'; $RAT .= ''; $RAT .= '
'; $RAT .= ''; return $RAT; } function generate_live_editor(){ $editors = array(); $editors['sitewide_editor'] = 'Site Layout / Options'; $editors['sitewide_style'] = 'Sitewide Styling'; $editors['banner'] = 'Header - Banner / Logo'; $editors['titlebar'] = 'Header - Title Bar'; $editors['sub-header'] = 'Navigation Bar'; $editors['social_editor'] = 'Custom Button Bar'; $editors['footer'] = 'Footer Styling'; $editors['seo'] = 'SEO Enhancements'; if($this->is_advanced()){ $editors['script_editor'] = 'Script / CSS Includes'; $editors['analytics'] = 'Analytics'; $editors['sitewide_settings'] = 'Backup / Restore';//'Settings / Tools'; if($this->is_api()){$editors['amptools'] = 'WP AMP Tools API';} } $docdata = $this->get_document_data(); $pageid = $docdata['pageid']; echo '
'; echo '
'; echo '
'; //echo '
AMP PublisherAMP Theme
'; echo '
AMP Publisher
'; echo '
'; echo 'Preview'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo 'Site Settings'; echo '
'; if($this->is_advanced()){ if(is_single() or is_page() or is_category() or $pageid==0){ echo '
'; echo 'Live Composer'; echo '
'; } }else{ echo '
'; echo 'Page Options'; echo '
'; } echo '
'; $lestat = $this->report_notices(); $leclass = '';if($lestat!=''){$leclass = 'notices';} echo '
'; echo '
'.$lestat.'
'; echo '
'; echo '
Save Changes
'; echo '
'; echo '
'; echo '
'; echo '
'; $comclass = '';if($this->is_advanced()){$comclass = ' class="advison"';} echo '
'; echo '
'; foreach($editors as $editor=>$ttl){ echo '
'; $icn = 'paint-brush'; if($editor=='sitewide_editor'){$icn = 'gears';} if($editor=='sitewide_settings'){$icn = 'hdd-o';} if($editor=='analytics'){$icn = 'bar-chart';} if($editor=='script_editor'){$icn = 'code';} if($editor=='seo'){$icn = 'globe';} if($editor=='amptools'){$icn = 'download';} echo '
'.$ttl.'
'; echo '
'; $this->ajax_load_editor(array('id'=>$editor,'typ'=>'editor')); echo '
'; echo '
'; } echo '
'; if(is_single() or is_page() or is_category() or $pageid==0){ echo '
'; } echo '
'; echo '
'; } function generate_live_select($id,$val,$opts,$flag=''){ $RAT = ''; $RAT .= ''; return $RAT; } function generate_live_textarea($id,$val,$flag=''){ //return ''; return ''; } function generate_live_textfield($id,$val,$filter='safe',$flag=''){ if($filter==''){$filter = 'safe';} $keydown = ' onkeydown="return inputfilter_'.$filter.'(event);"'; if($filter=='none'){$keydown = '';} return ''; } function generate_mobile_menu_block($params=array()){ $RAT = ''; $block = $this->get_customizer_setting('mobilemenu_block','post'); $type = $this->get_value($params,'type',$block); if($type=='post' or $type=='page'){ $atts = shortcode_atts(array('number'=>3,'excerpt_words'=>50,'post_type'=>$type),array()); $RAT .= $this->generate_mobile_menu_latest($atts); }else{ if($type=='custom'){ $content = $this->get_customizer_setting('mobilemenu_custom'); $content = $this->htmlout($content); $content = $this->content_filter($content,true); $RAT .= $content; } } return $RAT; } function generate_mobile_menu_latest($atts){ $RAT = ''; $type = $this->get_value($atts,'post_type','post'); $limit = $this->get_value($atts,'number',2); $exc = $this->get_value($atts,'excerpt_words',20); global $wpdb; $homeid = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = 'home'"); $args = array( 'numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => $homeid, 'meta_key' => '', 'meta_value' =>'', 'post_type' => $type, 'post_status' => 'publish', 'suppress_filters' => true ); $recent_posts = wp_get_recent_posts( $args, $output = ARRAY_A ); $list = array(); foreach($recent_posts as $dex=>$data){ $post_id = $this->get_value($data,'ID'); if($post_id!=''){ $ttl = $this->get_value($data,'post_title'); $url = esc_url(get_permalink($post_id)); $txt = $this->get_excerpt_by_id($post_id,20); $RAT .= '

'.$ttl.'

'.$txt.'... Read More
'; } } return $RAT; } function generate_object_page_query($pageid,$pagetype,$ands=NULL){ $and = ''; if($ands!=NULL){ if(is_string($ands)){ if($ands!=''){$and = $ands;} }else{ if(count($ands)>0){ foreach($ands as $dex=>$vex){ $and = $this->delimitit($and,' AND ',"`$dex`='$vex'"); } } } } if($and!=''){$and = ' AND '.$and;} return "WHERE ((`pid`='$pageid' AND `PageType`='$pagetype') OR `pid`='0')".$and; } function generate_page_content($content='',$pageid=NULL,$pagetype=NULL){ $RAT = ''; $barred = ''; $bar = $this->is_sidebar($pageid,$pagetype); if($bar!='' and $bar!='na'){$barred = ' sidebarred';} $RAT .= '
'; $RAT .= '
'; $RAT .= $content; $RAT .= '
'; $RAT .= '
'; $this->theme_template('sidebar'); $RAT .= '
'; return $RAT; } function generate_placeholder($mod,$pass='',$over=''){ $RAT = ''; if($mod=='ad'){$mod = 'AD';} $RAT .= '
'; $RAT .= '
AMP '.$this->ucwords_undash($mod).' Module
'; if($pass!=''){$RAT .= '
'.$pass.'
';} $RAT .= '
'; return $RAT; } function generate_post($data,$how='',$ampd=false){ $post_id = $this->get_value($data,'ID'); $ttl = $this->get_value($data,'post_title'); $date = $this->get_value($data,'post_date'); $height = $this->get_value($data,'height',300); $twid = $this->get_value($data,'thumbwidth',150); $thit = $this->get_value($data,'thumbheight','auto'); $display = $this->get_value($data,'display','article'); $url = esc_url(get_permalink($post_id)); $txt = $this->get_excerpt_by_id($post_id,30); $img = $this->get_default_image(); $imgwid = 880; $imghit = 557; if(has_post_thumbnail($post_id)){ $imgid = get_post_thumbnail_id($post_id); $img = wp_get_attachment_url($imgid); $imgdata = wp_get_attachment_metadata($imgid,true); $iwid = $this->get_value($imgdata,'width'); $ihit = $this->get_value($imgdata,'height'); if($iwid!=''){$imgwid = $iwid;} if($ihit!=''){$imghit = $ihit;} } $timetxt = ''; if($date!=''){$timetxt = date("M j, Y",strtotime($date));} $author = ''; $authorid = $this->get_value($data,'post_author'); if($authorid!=''){ $user = get_userdata($authorid); $author = $this->get_value($user,array('data','display_name')); } $cats = $this->get_post_category($post_id,'all','array'); $notags = false; $tags = array(); if(count($cats)>0){ foreach($cats as $cat){ $catid = $this->get_value($cat,'term_id'); if($catid>1 or $notags){ $catname = $this->get_value($cat,'name'); $catlink = $this->get_category_link($catid); $tags[$catname] = $catlink; } } } if(count($tags)==0){ $thetags = wp_get_post_tags($post_id); if(count($thetags)>0){ foreach($thetags as $term){ $catid = $this->get_value($term,'term_id'); $catname = $this->get_value($term,'name'); $catlink = get_tag_link($catid); if($catlink!='' and $catname!=''){$tags[$catname] = $catlink;} } } } if($how=='array'){return array('title'=>$ttl,'snippet'=>$txt,'image'=>$img,'wid'=>$imgwid,'hit'=>$imghit,'link'=>$url,'tags'=>$tags,'date'=>$timetxt,'author'=>$author);} $addhit = ''; if(substr($display,0,5)=='image'){$addhit .= ' hit-'.$height;} if($display=='thumbnail'){$addhit .= ' wid-'.$twid;} $RAT = ''; $RAT .= '
'; $RAT .= '
'; if(count($tags)>0){ $RAT .= '
'; foreach($tags as $tag=>$tagurl){ $RAT .= ''.$tag.''; } $RAT .= '
'; } $RAT .= '
'; $RAT .= ''; $imgadd = ''; $imgd = ''; if($display=='thumbnail'){ if($thit=='auto'){ if($ampd){ $imgadd .= ' width="'.$imgwid.'" height="'.$imghit.'" layout="responsive" class="ampimage"'; }else{ $sthit = floor($imghit/$imgwid*$twid); $imgadd .= ' width="'.$twid.'" height="'.$sthit.'" layout="responsive" class="ampimage"'; } }else{ $imgadd .= ' width="'.$twid.'" height="'.$thit.'" layout="fixed" class="ampimage"'; } }else{ if($ampd){$imgd = 'amp-';$imgadd .= ' width="'.$imgwid.'" height="'.$imghit.'" layout="responsive" class="ampimage"';} } if($ampd){$imgd = 'amp-';} if($display=='thumbnail'){$RAT .= '';} $RAT .= '<'.$imgd.'img src="'.$img.'"'.$imgadd.'>'; // placeholder and fallback if any $RAT .= ''; if($display=='thumbnail'){$RAT .= '';} $RAT .= ''; $RAT .= '
'; $RAT .= '
'; $RAT .= '

'.$ttl.'

'; $RAT .= ''; $RAT .= ''; $txt = $this->content_filter($txt,$ampd); $RAT .= $txt; $RAT .= '... Read More'; $RAT .= ''; $RAT .= '
'; $RAT .= '
'; $RAT .= '
'; $RAT .= '
'; $RAT .= '
'; $RAT .= '
'; return $RAT; } function generate_posts($params=array()){ $RAT = ''; $post_type = $this->get_value($params,'post_type','post'); $limit = $this->get_value($params,'limit',4); $display = $this->get_value($params,'display','article'); $postby = $this->get_value($params,'postby','recent'); $height = $this->get_value($params,'height',300); $twid = $this->get_value($params,'thumbwidth',150); $thit = $this->get_value($params,'thumbheight','auto'); $title = $this->get_value($params,'Title'); $category = 0; $include = ''; $ampd = $this->is_amp(); $imgd = ''; if($ampd){$imgd='amp-';} if($display=='onethree'){$limit = 4;} global $wpdb; $homeid = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = 'home'"); $doc = $this->get_document_data(); $pageid = $this->get_value($doc,'pageid'); $pagetype = $this->get_value($doc,'pagetype'); $homeid = $this->delimitit($homeid,',',$pageid); $catt = ''; $tagg = ''; $order = 'DESC'; $orderby = 'post_date'; if($postby=='popular' or $postby=='featured'){ if($postby=='featured'){ $arr = $this->queryit('select','settings',array('PageType'=>$post_type,'Var'=>'featured','Val'=>'true'),'ORDER BY `id` DESC LIMIT '.$limit); }else{ $arr = $this->queryit('select','settings',array('PageType'=>$post_type,'Var'=>'pageviews'),'ORDER BY `Val` DESC LIMIT '.$limit); $orderby = 'post__in'; } $includes = array(); if($this->validsql($arr)){ foreach($arr as $data){ $pid = $this->get_value($data,'pid'); if($pid!=''){$includes[] = $pid;} } } if(count($include)>0){$include = implode(',',$includes);} }else if($postby=='related'){ if($pagetype=='category'){ $category = $pageid; }else{ $cata = array(); $cats = $this->get_value($doc,'categories'); if($cats!=''){ foreach($cats as $cat){ $tid = $this->get_value($cat,'term_id'); if($tid!=''){$catt = $this->delimitit($catt,',',$tid);} } } if($catt!=''){$category = $catt;} $tags = wp_get_post_tags($pageid); if(count($tags)>0){ foreach($tags as $tag){ $tid = $this->get_value($tag,'term_id'); if($tid!=''){$tagg = $this->delimitit($tagg,',',$tid);} } } } }else{ if($pagetype=='category'){$category = $pageid;} } $args = array( 'numberposts' => $limit, 'offset' => 0, 'category' => $category, 'orderby' => $orderby, 'order' => $order, 'include' => $include, 'exclude' => $homeid, 'post_type' => $post_type, 'post_status' => 'publish', 'suppress_filters' => true ); $arr = get_posts($args,$output=ARRAY_A); $arrs = count($arr); if($arrs<$limit and $tagg!=''){ $args = array( 'numberposts' => ($limit-$arrs), 'offset' => 0, 'orderby' => $orderby, 'order' => $order, 'include' => $include, 'exclude' => $homeid, 'post_type' => $post_type, 'post_status' => 'publish', 'tax_query'=>array(array('taxonomy'=>'post_tag','field'=>'term_id','terms'=>$tagg)), 'suppress_filters' => true ); $brr = get_posts($args,$output=ARRAY_A); if(count($brr)>0){$arr = array_merge($arr,$brr);} } $list = array(); $pdis = $display; if(substr($display,0,5)=='image'){$pdis = 'image posts-'.$display;} if(substr($display,0,7)=='article' and $display!='article'){$pdis = 'article posts-'.$display;} $ascar = array(); $carousel = false; if($display=='slideshow' or $display=='flipper' or $display=='carousel'){$carousel = true;} $RAT .= '
'; if(count($arr)>0){ foreach($arr as $data){ $post_id = $this->get_value($data,'ID'); if($post_id!=''){ $data->height = $height; $data->thumbwidth = $twid; $data->thumbheight = $thit; $data->display = $display; if($carousel){ $ascar[] = $this->generate_post($data,'array',$ampd); }else{ $RAT .= $this->generate_post($data,'',$ampd); } } } }else{ $RAT .= '

No posts were found for this module

'; } $RAT .= '
'; if($carousel){ $cars = array(); $cars['height'] = $height; $cars['display'] = $display; $cars['ampd'] = $ampd; $cars['id'] = 'posts'; $cars['slides'] = $ascar; $RAT = $this->generate_carousel($cars);// WPTASK - THIS OPTION ONLY EXISTS WITH PLUGIN, BUT MUST REMAIN HERE } return $RAT; } function generate_social_bar(){ $RAT = ''; $list = $this->get_customizer_setting('social_buttonlist'); if($list!=''){ $exp = explode('[JJ]',$list); foreach($exp as $part){ $parts = explode('[DD]',$part); $icon = $this->get_value($parts,0); $url = $this->get_value($parts,1); $ttl = $this->get_value($parts,2); $RAT .= '
  •  
  • '; } } $usefeed = $this->get_customizer_setting('social_rssfeed'); if($usefeed==''){ $feedurl = $this->get_site_base_url().'/feed'; $RAT .= '
  •  
  • '; } return $RAT; } function generate_social_button_item($data){ $icon = $this->get_value($data,'icon'); $url = $this->get_value($data,'url'); $ttl = $this->get_value($data,'title'); $RAT = ''; $RAT .= '
    '; $RAT .= '
    '; $RAT .= '
    '; $RAT .= '
    '; $RAT .= '
    '; $RAT .= '
    '; $RAT .= 'Link URL'; $RAT .= ''; $RAT .= 'Title (SEO information)'; $RAT .= ''; $RAT .= '
    '; $RAT .= '
    '; return $RAT; } function generate_social_button_manager(){ $RAT = ''; $RAT .= 'Choose an Icon to Create a Button'; $list = $this->get_customizer_setting('social_buttonlist'); $RAT .= '
    '; if($list!=''){ $exp = explode('[JJ]',$list); foreach($exp as $part){ $parts = explode('[DD]',$part); $icon = $this->get_value($parts,0); $url = $this->get_value($parts,1); $ttl = $this->get_value($parts,2); $RAT .= $this->generate_social_button_item(array('icon'=>$icon,'url'=>$url,'title'=>$ttl)); } } $RAT .= '
    '; return $RAT; } function generate_video_module($attrs,$ampd=false){ $RAT = ''; $provider = $this->get_value($attrs,'provider'); $source = $this->get_value($attrs,'sourcecode'); $aspect = $this->get_value($attrs,'aspectratio'); $width = 16; $height = 9; $layout = 'responsive'; if($layout=='responsive' and $aspect!=''){ $vals = explode('x',$aspect); $xwid = $this->get_value($vals,0,$width); $xhit = $this->get_value($vals,1,$height); $width = $xwid; $height = $xhit; } $atts = ''; $warn = ''; $vidttl = ''; if($provider==''){ $warn = 'You must choose a Provider'; }else{ $providers = array('reach-player'=>'Beachfront Reach','brid-player'=>'Brid.tv','dailymotion'=>'Dailymotion','facebook'=>'Facebook','vimeo'=>'Vimeo','youtube'=>'YouTube','video'=>'Local Media File'); $vars = array('reach-player'=>'embed-id','brid-player'=>'video','dailymotion'=>'videoid','facebook'=>'href','vimeo'=>'videoid','youtube'=>'videoid'); $ttls = array('reach-player'=>'Embed ID','brid-player'=>'Video ID','dailymotion'=>'Video ID','facebook'=>'Video URL','vimeo'=>'Video ID','youtube'=>'Video ID'); $pass = ''.$this->get_value($providers,$provider).''; $ttl = $this->get_value($ttls,$provider); if($provider=='brid-player'){ $partner = $this->get_value($attrs,'partner'); $player = $this->get_value($attrs,'player'); $video = $this->get_value($attrs,'video'); $playlist = $this->get_value($attrs,'playlist'); if($partner=='' or $player==''){ $warn = 'You must enter your Brid.tv "Partner ID" and "Player ID"'; }else if($video=='' and $playlist==''){ $warn = 'You must enter either a Brid.tv "Video ID" or "Playlist ID"'; }else{ $atts .= ' data-partner="'.$partner.'"'; $atts .= ' data-player="'.$player.'"'; if($play!=''){ $atts .= ' data-playlist="'.$play.'"'; $vidttl = 'Playlist ID: '.$video; }else{ $atts .= ' data-video="'.$video.'"'; $vidttl = 'Video ID: '.$video; } } }else{ $vidvar = ''; if($provider=='vimeo' or $provider=='dailymotion' or $provider=='youtube'){ $vidvar = 'videoid'; }else if($provider=='reach-player'){ $vidvar = 'embed-id'; }else if($provider=='facebook'){ $vidvar = 'href'; $atts .= ' data-embed-as="video"'; }else if($provider=='video'){ if(strstr($video,'wp-content/uploads')){ $exp = explode('wp-content/uploads',$video); $path = $this->get_value($exp,1); if($path!=''){ $vidvar = 'video'; $atts .= ' controls'; $atts .= ' src="../wp-content/uploads'.$path.'"'; $atts .= ' poster="'.$this->self['PATH'].'images/vidposter.jpg"'; } } } if($vidvar!=''){ if($source=='shortcode'){ $video = $this->get_value($attrs,'video'); }else{ $video = $this->get_value($attrs,$vidvar); } $prov = $providers[$provider]; if($video==''){ $warn = 'You must enter your '.$prov.' "'.$ttl.'"'; }else{ $atts .= ' data-'.$vidvar.'="'.$video.'"'; if($provider=='facebook' or $provider=='video'){ $vidttl = $video; }else{ $vidttl = $this->get_value($ttls,$provider).': '.$video; } } } } } if($ampd and $warn==''){ $RAT .= ''; }else{ if($provider==''){ $pass = $this->generate_warning($warn); }else{ $pass = ''.$providers[$provider].''; if($warn==''){ $pass .= '
    '.$vidttl.''; }else{ $pass .= $this->generate_warning($warn); } } $over = ''; if($ampd){$over = 'amp';} $RAT .= $this->generate_placeholder('video',$pass,$over); } return $RAT; } function generate_warning($pass){ $RAT = ''; $RAT .= ''.$pass.''; return $RAT; } function get_attachment_id_from_url($image_url) { global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url )); return $attachment[0]; } function get_dat($var,$def=''){ return $this->htmlout($this->queryit('get','dats','Val',array('Var'=>$var))); } function get_default_image(){ $def = $this->get_customizer_setting('site_defaultimage'); if($def!=''){return $def;} return $this->self['PATH'].'images/no-image-found.jpg'; } function get_document_data(){ $jsontype = 'WebPage'; $url = $this->current_page_url(); $headline = $this->get_page_title(); $desc = ''; $contype = 'website'; $title = $headline; $sitename = get_bloginfo('title'); if(is_home() or is_front_page()){ $headline = $sitename; $jsontype = 'WebSite'; $desc = get_bloginfo('description'); }else{ if(is_category()){ $jsontype = 'WebSite'; }else{ if(is_single()){$jsontype = 'NewsArticle';} $contype = 'article'; } } $published = ''; $modified = ''; $author = ''; $authorid = ''; if(is_category()){ $term_id = $this->get_category_id(); $data = get_category($term_id); $pageid = $term_id; $pagetype = 'category'; }else if(is_front_page() or is_home()){ $data = get_post(); $post_id = $this->get_value($data,'ID'); $post_type = $this->get_value($data,'post_type'); if($post_type=='page'){ $pageid = $post_id; $pagetype = 'page'; }else{ $pageid = 0; $pagetype = 'post'; } }else{ $data = get_post(); $post_id = $this->get_value($data,'ID'); $authorid = $this->get_value($data,'post_author'); $published = $this->get_value($data,'post_date'); $modified = $this->get_value($data,'post_modified'); $published = str_replace(' ','T',$published); $modified = str_replace(' ','T',$modified); $pageid = $post_id; $pagetype = $this->get_value($data,'post_type'); } if($authorid!=''){$author = get_the_author_meta('nicename',$authorid);} if($published==''){$published = date('Y-m-dTh:i:sZ',time());} $logow = ''; $logoh = ''; $imgw = ''; $imgh = ''; $images = array(); $logo = $this->get_customizer_setting('header_logoimage'); if($logo!=''){ $logow = $this->get_image_info($logo,'width'); $logoh = $this->get_image_info($logo,'height'); } $img = $this->get_featured_image($pageid); if($img!=''){ $imgw = $this->get_image_info($img,'width'); $imgh = $this->get_image_info($img,'height'); } $publisher = get_bloginfo('name'); $publishertype = 'Organization'; $category = ''; $categories = ''; if(is_single()){ $category = $this->get_post_category(); $categories = $this->get_post_category($pageid,'all','array'); } $DAT = array(); $DAT['pagetype'] = $pagetype; $DAT['pageid'] = $pageid; $DAT['jsontype'] = $jsontype; $DAT['url'] = $url; $DAT['headline'] = $headline; $DAT['desc'] = $desc; $DAT['contype'] = $contype; $DAT['title'] = $title; $DAT['sitename'] = $sitename; $DAT['published'] = $published; $DAT['modified'] = $modified; $DAT['author'] = $author; $DAT['authorid'] = $authorid; $DAT['publisher'] = $publisher; $DAT['publishertype'] = $publishertype; $DAT['logo'] = $logo; $DAT['logow'] = $logow; $DAT['logoh'] = $logoh; $DAT['img'] = $img; $DAT['imgw'] = $imgw; $DAT['imgh'] = $imgh; $DAT['images'] = $images; $DAT['category'] = $category; $DAT['categories'] = $categories; return $DAT; } function get_page_setting($id,$type,$var){ return $this->htmlout($this->queryit('get','settings','Val',array('pid'=>$id,'PageType'=>$type,'Var'=>$var))); } function get_size_choices($how=''){ $RET = array(); $pre = substr($how,0,5); if($how=='auto' or $how=='thumbheight'){$RET ['auto'] = 'Auto';} $RET['100'] = '100px'; if($pre=='thumb'){ $RET['110'] = '110px'; $RET['120'] = '120px'; $RET['130'] = '130px'; $RET['140'] = '140px'; } $RET['150'] = '150px'; if($pre=='thumb'){ $RET['160'] = '160px'; $RET['170'] = '170px'; $RET['180'] = '180px'; $RET['190'] = '190px'; } $RET['200'] = '200px'; if($pre=='thumb'){ $RET['220'] = '220px'; $RET['240'] = '240px'; $RET['260'] = '260px'; $RET['280'] = '280px'; } $RET['300'] = '300px'; if($pre!='thumb'){ $RET['400'] = '400px'; $RET['500'] = '500px'; $RET['600'] = '600px'; } return $RET; } function get_social_network_data($network=NULL){ $RET['facebook'] = array('icon'=>'facebook','square'=>'facebook-square','color'=>'#3b5998','title'=>'Facebook'); $RET['flickr'] = array('icon'=>'flickr','color'=>'#dc4e41','title'=>'Flickr'); $RET['gplus'] = array('icon'=>'google-plus','square'=>'google-plus-square','color'=>'#D51F1E','title'=>'Google+'); $RET['instagram'] = array('icon'=>'instagram','color'=>'#F00','title'=>'Instagram'); $RET['linkedin'] = array('icon'=>'linkedin','square'=>'linkedin-square','color'=>'#0077b5','title'=>'LinkedIn'); $RET['pinterest'] = array('icon'=>'pinterest-p','square'=>'pinterest-square','color'=>'#bd081c','title'=>'Pinterest'); $RET['tumblr'] = array('icon'=>'tumblr','square'=>'tumblr-square','color'=>'#33465D','title'=>'Tumblr'); $RET['twitter'] = array('icon'=>'twitter','square'=>'twitter-square','color'=>'#55acee','title'=>'Twitter'); $RET['vimeo'] = array('icon'=>'vimeo','square'=>'vimeo-square','color'=>'#1AB7EA','title'=>'Vimeo'); $RET['youtube'] = array('icon'=>'youtube-play','square'=>'youtube-square','color'=>'#DD2623','title'=>'YouTube'); if($network!='social'){ $RET['email'] = array('icon'=>'envelope-o','square'=>'envelope-square','color'=>'#000','title'=>'Email'); $RET['rss'] = array('icon'=>'rss','square'=>'rss-square','color'=>'#F90','title'=>'RSS Feed'); } if($network!=NULL and $network!='social'){return $this->get_value($RET,$network,array());} return $RET; } function include_amp_module($mod){ echo ''; } function include_amp_modules(){ $used = array(); $this->include_amp_module('form');$used['form'] = true; $this->include_amp_module('sidebar');$used['sidebar'] = true; if($this->is_advanced()){$used = $this->adv_amp_modules($used);} } function is_amp($com=''){ if($com!='not'){ if($this->get_value($_GET,'commenting')=='1'){return false;} if($this->get_value($_GET,'useforms')=='1'){return false;} } if($this->get_value($_GET,'amp')=='1'){return true;} if($this->is_user_admin()){return false;} return true; } function is_amp_not(){ if($this->is_amp('not')){ if($this->get_value($_GET,'commenting')=='1'){return true;} if($this->get_value($_GET,'useforms')=='1'){return true;} } //if($this->is_amp('not') and $this->get_value($_GET,'commenting')=='1'){return true;} return false; } function is_archive_preview(){ if($this->get_value($_GET,'amp')=='1' and $this->get_value($_GET,'archivepreview')=='1' and $this->get_value($_GET,'id')!='' and $this->get_value($_GET,'aid')!='' and $this->get_value($_GET,'how')!=''){ return true; } return false; } function is_comments(){ if($this->is_comments_wp() && $this->get_value($_GET,'commenting')=='1'){return true;} return false; } function is_comments_wp(){ if((!is_admin()) && is_singular() && comments_open() && get_option('thread_comments')){return true;} return false; } function is_sidebar($pageid=NULL,$pagetype=NULL){ $hid = $this->get_page_setting($pageid,$pagetype,'hidesidebar'); if($hid===true or $hid==='true'){return '';} $data = $this->get_document_data(); $pagetype = $this->get_value($data,'pagetype'); $pageid = $this->get_value($data,'pageid'); $pageurl = $this->get_value($data,'url'); $blogurl = $this->get_site_base_url(); $fhome = false; if($pageurl!=''){ $purls = explode('?',$pageurl); $purl = $purls[0]; $furl = str_replace($blogurl,'',$purl); if(substr($furl,0,1)=='/'){$furl = substr($furl,1);} if($furl==''){$fhome = true;} } $sid = ''; if(is_category()){ $sid = 'category'; }else if(is_home() and is_front_page()){ $sid = 'home';// default }else if(is_front_page()){ $sid = 'home';// front }else if(is_home()){ $sid = 'home'; if($pagetype=='post' and $pageid=='0'){ if($fhome==true){ $sid = 'home';// default }else{ $sid = 'category';// blog } } }else if(is_page()){ $sid = 'page'; }else if(is_single()){ $sid = 'post'; }else if(is_archive()){ $sid = 'archive'; } $side = $sid.'sidebar'; if($this->get_customizer_setting('site_hide'.$side)!=''){return '';} if(is_active_sidebar($side)){return $side;} if($this->is_advanced()){if($this->adv_is_sidebar($pageid,$pagetype)!='na'){return $side;}} if(is_active_sidebar('sitesidebar')){return $side;} return 'na'; } function page_navigation() { global $wp_query; $bignum = 999999999; if ( $wp_query->max_num_pages <= 1 ){return;} echo '