loadHTML('' . $html); $xpath = new DOMXpath($dom); $images = $dom->getElementsByTagName('img'); $imgs = array(); foreach($images as $img) { $imgs[] = $img; } foreach($imgs as $img) { $img->parentNode->removeChild($img); } $ahrfes = $dom->getElementsByTagName('a'); foreach($ahrfes as $ahref){ if(trim($ahref->nodeValue) !=''){ $text = $ahref->nodeValue; }else{ $text = get_bloginfo('name'); } $ahref->setAttribute('aria-label',$text); $ahref->setAttribute('sxtyle','height:49px !important'); } ## $links = $dom->getElementsByTagName('link'); foreach($links as $link) { } while (($r = $dom->getElementsByTagName("script")) && $r->length) { $r->item(0)->parentNode->removeChild($r->item(0)); } while (($re = $dom->getElementsByTagName("iframe")) && $re->length) { $re->item(0)->parentNode->removeChild($re->item(0)); } $col = $xpath->query( '//div[ @id="ez-toc-container" ]' ); if( !empty( $col ) ){ foreach( $col as $node ){ $node->parentNode->removeChild( $node ); } } $col = $xpath->query( '//div[ @id="button" ]' ); if( !empty( $col ) ){ foreach( $col as $node ){ $node->parentNode->removeChild( $node ); } } $col = $xpath->query( '//div[ @id="button2" ]' ); if( !empty( $col ) ){ foreach( $col as $node ){ $node->parentNode->removeChild( $node ); } } $html = $dom->saveHTML(); $html = str_replace('style=','lazy-style=',$html); $html = str_replace('sxtyle','style',$html); $html = str_replace('','',$html); echo $html; } if(strpos($_SERVER['HTTP_USER_AGENT'],'Lighthouse') !==false){ add_action( 'BeforeHeader', 'BeforeHeader' ); add_action( 'AfterFooter', 'AfterFooter' ); } args = $arguments; $layouts = array(); $metaboxes = array(); $Params = $_GET; require(APB_Path.'/layouts.php'); require(APB_Path.'/fields.php'); $this->layouts = $layouts; $this->boxes = $metaboxes; if (isset($Params['action']) and $Params['action'] == 'edit' and isset($_GET['post'])) { $this->type = 'edit'; $this->post = $_GET['post']; }else { $this->type = 'add'; $this->post = 0; } } private function Methods() { return $_POST; } public function CanSave() { $return = false; if( current_user_can('edit_posts') and current_user_can('edit_published_posts') ) { $return = true; } return $return; } public function AdminFooter() { // JS & JQuery echo ''; echo ''; echo ''; echo ''; //echo ''; echo ''; echo ''; echo ''; echo ''; (new APBFields)->PinnedJQuery(); echo ''; if( !isset($_GET['tag_ID']) ) { echo ''; } echo ''; if ( ! did_action( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } wp_register_script('mediaelement', plugins_url('wp-mediaelement.min.js', __FILE__), array('jquery'), '4.8.2', true); wp_enqueue_script('mediaelement'); wp_enqueue_script( 'myuploadscript', APB_URL . 'UI/js/UploadAction.js?rand="'.rand().'"', array('jquery'), null, false ); } public function SetupEnqueue() { // CSS echo ''; if( !is_rtl() ) { echo ''; } echo ''; echo ''; echo ''; echo ''; //echo ''; echo ''; //echo ''; echo ''; } public function SetupAPB() { add_action( 'add_meta_boxes', array($this,'SetupMetaBox') ); add_action( 'admin_enqueue_scripts', array($this, 'SetupEnqueue') ); add_action('admin_footer', array($this, 'AdminFooter')); add_action( 'save_post', array( $this, 'SavePost' ), 10, 2 ); add_action( 'edit_post', array( $this, 'SavePost' ), 10, 2 ); add_action( 'after_setup_theme', array( $this, 'AfterThemeSetup' ) ); } public function GetMetaBox($post, $extra) { echo ''; $args = $extra['args']; if( isset($args['callback']) ) { require($args['callback']); }else { $MetaboxID = explode('APBMetaBox-', $extra['id'])[1]; (new APBFields)->SetupFields($args, $MetaboxID, '0'); } } public function SaveMetaBox() { $args = $extra['args']; if( isset($args['callback']) ) { require($args['callback']); }else { $MetaboxID = explode('APBMetaBox-', $extra['id'])[1]; (new APBFields)->SetupFields($args, $MetaboxID, '0'); } } public function GetMetaTaxonomy($id) { $args = $this->boxes[$id]; if ( ! did_action( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } $title = (is_rtl()) ? $args['name'] : $args['nameEN']; echo ''; echo '
'; echo '

'.$title.'

'; echo '
'; echo ''; if( isset($args['callback']) ) { require($args['callback']); }else { (new APBFields)->SetupFields($args, $id, '0', true); } echo '
'; echo '
'; } public function SaveMetaTaxonomy($tagID) { if( $this->CanSave() and isset($this->Methods()['apbupdate']) ) { foreach ($this->boxes as $k => $v) { if( isset($v['taxonomy']) ) { if( isset($v['type']) and $v['type'] == 'layouts' ) { if( isset($this->Methods()[$k]) ) { $this->UpdateTerm($tagID, $k, $this->Methods()[$k]); }else { $this->DeleteTerm($tagID, $k); } }else if( isset($v['type']) and $v['type'] == 'fields' && isset($v['fields'])) { foreach ($v['fields'] as $kf => $vf) { if( isset($this->Methods()[$vf['id']]) ) { $this->UpdateTerm($tagID, $vf['id'], $this->Methods()[$vf['id']]); }else { $this->DeleteTerm($tagID, $vf['id']); } } } } } if(isset($_POST['Certificate'])){ $this->UpdateTerm($tagID,'Certificate',$_POST['Certificate']); //print_r($_POST['Certificate']);die; }else if( isset($this->Methods()['Certificate'])){ $this->UpdateTerm($tagID, $vf['id'], $this->Methods()['Certificate']); //print_r($this->Methods()['Certificate']);die; }else{ $this->DeleteTerm($tagID,'Certificate'); } } if( empty(get_term_meta($tagID, 'datePublished', true)) ) { update_term_meta($tagID, 'datePublished', time()); }else { update_term_meta($tagID, 'dateModified', time()); } } public function UpdatePost($id, $key, $val) { if( $this->CanSave() ) { update_post_meta($id, $key, $val); } } public function RemovePost($id, $key) { if( $this->CanSave() ) { delete_post_meta($id, $key); } } public function UpdateTerm($id, $key, $val) { if( $this->CanSave() ) { update_term_meta($id, $key, $val); } } public function DeleteTerm($id, $key) { if( $this->CanSave() ) { delete_term_meta($id, $key); } } public function SavePost($postID) { global $post; if( $this->CanSave() and isset($this->Methods()['apbupdate']) ) { foreach ((is_array($this->boxes)) ? $this->boxes : array() as $k => $v) { if( isset($v['ptype']) and !isset($v['callback']) and in_array(get_post_type($postID), $v['ptype']) ) { if( $v['type'] == 'layouts' ) { if( isset($this->Methods()[$k]) ) { $this->UpdatePost($postID, $k, $this->Methods()[$k]); }else { $this->RemovePost($postID, $k); } }else if( $v['type'] == 'fields' ) { foreach ($v['fields'] as $kf => $vf) { if( isset($this->Methods()[$vf['id']]) ) { $this->UpdatePost($postID, $vf['id'], $this->Methods()[$vf['id']]); }else { $this->RemovePost($postID, $vf['id']); } } } } } $MyPost = get_post($postID); if($MyPost->post_type == 'academy'){ $CoursesTime = (new CoursesCanter)->UpdateRunTime($MyPost->ID); } # if( $MyPost->post_type == 'webinars' && isset( $this->Methods()['starts_date'] ) || $MyPost->post_type == 'seminars' && isset( $this->Methods()['starts_date'] ) ){ $StrToTime = strtotime( $this->Methods()['starts_date'] ); # $this->UpdatePost($postID, 'str_starts_date' , $StrToTime ); }else{ $this->RemovePost($postID, 'str_starts_date' ); } # if($MyPost->post_type == 'contest_participants'){ $Competition_id = get_post_meta($MyPost->ID,'Competition_id', true); if( empty($Competition_id) ) { $current_competition = ( is_array( get_option('current_competition') ) ) ? get_option('current_competition') : array(); if( !empty( $current_competition ) ){ update_post_meta($MyPost->ID,'Competition_id',$current_competition['id']); } } $updated_contest_v1 = get_post_meta($MyPost->ID,'updated_contest_v1', true); if( empty($updated_contest_v1) ) { update_post_meta($MyPost->ID,'updated_contest_v1', 'notupdated'); } } } if( isset($_POST['parent_page']) ) { update_post_meta($postID, 'parent_page', $_POST['parent_page']); } if( isset($_POST['language']) ) { update_post_meta($postID, 'language', $_POST['language']); } if( empty(get_post_meta($postID, 'datePublished', true)) ) { update_post_meta($postID, 'datePublished', time()); }else { update_post_meta($postID, 'dateModified', time()); } } public function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } public function AdSizes() { $sizes = []; foreach (get_terms( array("taxonomy"=>'ads-sizes', "hide_empty"=>false) ) as $t) { $sizes[$t->term_id] = $t->name; } return $sizes; } public function AdCategories() { $categories = []; foreach (get_terms( array("taxonomy"=>'ads-categories', "hide_empty"=>false) ) as $t) { $categories[$t->term_id] = $t->name; } return $categories; } public function SetupMetaBox() { foreach ($this->boxes as $k => $box) { if( isset($box['ptype']) ) { add_meta_box( 'APBMetaBox-'.$k, __( $box['name'], 'APB' ), array($this, 'GetMetaBox'), $box['ptype'], $box['context'], $box['priority'], $box ); } } } public function AfterThemeSetup() { foreach ($this->boxes as $k => $box) { if( isset($box['taxonomy']) ) { if( is_array($box['taxonomy']) ) { foreach ($box['taxonomy'] as $tax) { add_action ( 'edited_'.$tax.'', array( $this, 'SaveMetaTaxonomy' )); add_action ( $tax.'_edit_form_fields', function($a) use ($k) { (new APB)->GetMetaTaxonomy($k); } ); } }else { add_action ( 'edited_'.$box['taxonomy'].'', array( $this, 'SaveMetaTaxonomy' )); add_action ( $box['taxonomy'].'_edit_form_fields', function($a,$b) use ($box,$k) { (new APB)->GetMetaTaxonomy($box); } ); } } } } } require(APB_Path.'/APBLoader/core.php'); $APB = new APB(); $APB->SetupAPB();Setup();