Skip to content

安装后网站出现错误 #6

Description

@jsjjl

'; echo '
'.$this->pageinfo['full_name'].'
'; if(!empty($this->pageinfo['desc'])){ echo ''.$this->pageinfo['desc'].''; } echo '
'; echo '
'; $this->tab_toggle($this->options); foreach ($this->options as $option) { if( ( $option['type']=='open' || $option['type']=='close' || $option['type']=='title') || ( isset($option['id']) && method_exists($this, $option['type']) ) ) { if( !isset($option['std']) ) $option['std'] = ''; if( in_array($option['type'],array('text','textarea',)) && ( !empty($option['multiple']) && $option['multiple']==false ) ) $option['std'] = htmlspecialchars($option['std'],ENT_COMPAT, 'UTF-8'); $this->{$option['type']}($option); $saveoption = true; } } if($saveoption) { echo '
'; wp_nonce_field( 'ashuwp_framework_action','ashuwp_framework_field' ); echo '
'; } echo '
'; } function get_save_options() { $newoptions = $this->old_value; if( isset($_REQUEST['ashuwp_framework_field']) && check_admin_referer('ashuwp_framework_action', 'ashuwp_framework_field') ) { if(!empty($_POST['ashuwp_framework_reset'])){ echo '
Option reseted.

'; if( $this->is_network ){ delete_site_option( $this->saved_optionname ); }else{ delete_option( $this->saved_optionname ); } } if(!empty($_POST['ashuwp_framework_submit'])){ echo '
Settings saved.

'; foreach($this->options as $option) { if( $option['type'] == 'tinymce' ){ $value = stripslashes( $_POST[$option['id']] ); $newoptions[$option['id']] = $value; }elseif( ( !empty($option['multiple']) && $option['multiple']===true ) || $option['type'] == 'group' ){ if( !empty($_POST[$option['id']]) ){ $value = $_POST[$option['id']]; }else{ $value = ''; } $newoptions[$option['id']] = $value; }elseif( in_array( $option['type'], array('text','textarea') ) ){ $value = stripslashes( $_POST[$option['id']] ); $value = htmlspecialchars($value,ENT_COMPAT, 'UTF-8'); $newoptions[$option['id']] = $value; }elseif($option['type'] == 'checkbox'){ $newoptions[$option['id']] = empty($_POST[$option['id']]) ? array(): $_POST[$option['id']]; }elseif( $option['type'] == 'numbers_array' || $option['type'] == 'gallery' ){ $value = explode( ',', $_POST[$option['id']] ); $value = array_filter($value); $newoptions[$option['id']] = $value; }elseif( in_array( $option['type'], array('open','close','title') ) ){ continue; }else{ $value = htmlspecialchars($POST[$option['id']], ENT_QUOTES,"UTF-8"); $newoptions[$option['id']] = $value; } } if ( $this->old_value != $newoptions ) { if( $this->is_network ){ update_site_option( $this->saved_optionname, $newoptions ); }else{ update_option( $this->saved_optionname, $newoptions ); } } } do_action('ashuwp_custom_saved'); } }}ashu_feild = $ashu_feild; $this->taxonomy_conf = $taxonomy_conf; foreach($this->taxonomy_conf as $taxonomy){ add_action($taxonomy.'add_form_fields', array(&$this, 'taxonomy_fields_adds'), 10, 2); add_action($taxonomy.'edit_form_fields', array(&$this, 'taxonomy_metabox_edit'), 10, 2); add_action('created'.$taxonomy, array(&$this, 'save_taxonomy_metadata'), 10, 1); add_action('edited'.$taxonomy,array(&$this, 'save_taxonomy_metadata'), 10, 1); add_action('admin_enqueue_scripts', array(&$this, 'enqueue_css_js')); add_action( 'admin_footer', array(&$this, 'enqueue_html') ); add_action('delete'.$taxonomy, array(&$this,'delete_taxonomy_metadata'),10,1); } } function taxonomy_fields_adds(){ echo '
'; $this->tab_toggle($this->ashu_feild); foreach($this->ashu_feild as $ashu_feild){ if ( ( $ashu_feild['type']=='open' || $ashu_feild['type']=='close' ) || (isset($ashu_feild['id']) && method_exists($this, $ashu_feild['type'])) ){ if($ashu_feild['type']=='open' || $ashu_feild['type']=='close'){ $this->{$ashu_feild['type']}($ashu_feild); continue; } if($ashu_feild['type']=='tinymce'){ $this->reminder($ashu_feild); continue; } if($ashu_feild['type']=='open' || $ashu_feild['type']=='close'){ $this->{$ashu_feild['type']}($ashu_feild); continue; } if(!isset($ashu_feild['std'])) $ashu_feild['std'] = ''; $this->{$ashu_feild['type']}($ashu_feild); } } echo '
'; } function taxonomy_metabox_edit($tag){ echo '
'; $this->tab_toggle($this->ashu_feild); foreach($this->ashu_feild as $ashu_feild){ if ( ( $ashu_feild['type']=='open' || $ashu_feild['type']=='close' ) || (isset($ashu_feild['id']) && method_exists($this, $ashu_feild['type'])) ){ if($ashu_feild['type']=='open' || $ashu_feild['type']=='close'){ $this->{$ashu_feild['type']}($ashu_feild); continue; } $feild_value = get_term_meta($tag->term_id , $ashu_feild['id'],true); if( $feild_value != '' ){ $ashu_feild['std'] = $feild_value; } $this->{$ashu_feild['type']}($ashu_feild); } } echo '
'; } function delete_taxonomy_metadata($term_id){ foreach($this->ashu_feild as $ashu_feild){ if(isset($ashu_feild['id'])) delete_term_meta($term_id,$ashu_feild['id']); } } function save_taxonomy_metadata($term_id){ foreach($this->ashu_feild as $ashu_feild){ if( !empty($ashu_feild['id']) && isset($_POST[$ashu_feild['id']]) ){ if(!current_user_can('manage_categories')){ return; } $old_data = get_term_meta($term_id , $ashu_feild['id'],true); if( $ashu_feild['type'] == 'tinymce' ){ $data = stripslashes($_POST[$ashu_feild['id']]); }elseif( ( !empty($ashu_feild['multiple']) && $ashu_feild['multiple']===true ) || $ashu_feild['type'] == 'group' ){ if($_POST[$ashu_feild['id']]!=''){ $data = array_filter($_POST[$ashu_feild['id']]); }else{ $data = ''; } }elseif( $ashu_feild['type'] == 'checkbox' ){ $data = $_POST[$ashu_feild['id']]; }elseif( $ashu_feild['type'] == 'numbers_array' || $ashu_feild['type'] == 'gallery' ){ $data = explode( ',', $_POST[$ashu_feild['id']] ); $data = array_filter($data); }elseif( in_array( $ashu_feild['type'], array('open','close','title') ) ){ continue; }else{ $data = htmlspecialchars($_POST[$ashu_feild['id']], ENT_QUOTES,"UTF-8"); } if($data == "") delete_term_meta($term_id , $ashu_feild['id'], $data); else update_term_meta($term_id , $ashu_feild['id'], $data); }else{ delete_term_meta($term_id,$ashu_feild['id']); } } } function reminder($values){ if( !isset($values['id']) ) return; echo '
'; echo ''; if( isset($values['name']) ) echo $values['name']; echo ''; echo '
Please add this feild into the edit page.

'; echo '
'; }}
options = $ashu_option_conf; $this->pageinfo = $pageinfo; $this->saved_optionname = 'ashuwp_'.$this->pageinfo['optionname']; if( isset($this->pageinfo['network']) && is_multisite() && $this->pageinfo['network']==true ){ $this->is_network = true; }else{ $this->is_network = false; } add_action( $this->is_network ? 'network_admin_menu' : 'admin_menu', array(&$this, 'add_admin_menu') ); if( isset($_GET['page']) && ($_GET['page'] == $this->pageinfo['filename']) ) { add_action('admin_enqueue_scripts', array(&$this, 'enqueue_css_js')); add_action( 'admin_footer', array(&$this, 'enqueue_html') ); } } function add_admin_menu() { if($this->pageinfo['child']) { $parent_slug = $this->pageinfo['parent_slug']; add_submenu_page($parent_slug, $this->pageinfo['full_name'], $this->pageinfo['full_name'], 'manage_options', $this->pageinfo['filename'], array(&$this, 'initialize')); }else{ add_menu_page($this->pageinfo['full_name'], $this->pageinfo['full_name'], 'manage_options', $this->pageinfo['filename'], array(&$this, 'initialize'),'',26); } } function make_data_available() { if( $this->is_network ){ $this->old_value[$this->pageinfo['optionname']] = get_site_option( $this->saved_optionname ); }else{ $this->old_value[$this->pageinfo['optionname']] = get_option($this->saved_optionname); } $this->old_value = $this->htmlspecialchars_deep($this->old_value,ENT_QUOTES,'UTF-8'); foreach ($this->options as $key => $option) { if( isset($option['id']) && isset($this->old_value[$this->pageinfo['optionname']][$option['id']])){ $this->options[$key]['std'] = $this->old_value[$this->pageinfo['optionname']][$option['id']]; } } } function htmlspecialchars_deep ($mixed, $quote_style=ENT_QUOTES, $charset='UTF-8') { if (is_array($mixed)) { foreach ($mixed as $key => $value) { $mixed[$key] = $this->htmlspecialchars_deep($value, $quote_style, $charset); } } elseif (is_string($mixed)) { $mixed = htmlspecialchars_decode($mixed, $quote_style); } return $mixed; } function initialize() { $this->get_save_options(); $this->make_data_available(); $this->display(); } function display() { $saveoption = false; echo '

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions