mpanel = $mpanel; } /** * 选项样式 * * @TODO 太乱啦,看着就不想动手改造,反正也还能用,先这么放着,心情好再改,(*^__^*) !!! */ public function item( $args ) { $args = wp_parse_args( $args, array( 'type' => 'text', 'id' => false, 'name' => false ) ); if( $this->get_default ){ if( isset( $args['default'] ) ) $this->default[$args['id']] = $args['default']; return; } if( $args['type'] == 'help' ){ $id = $args['id'] ? ' id="' . 'mpanel-item-' . esc_attr( $args['id'] ) . '"' : ''; echo '
' . $args['name'] . '
'; return; } $option_value = $this->mpanel->get( $args['id'] ); if( $args['id'] ) $htmlid = esc_attr( 'mpanel-item-' . $args['id'] ); ?>
'; if( $args['name'] && $args['type'] != 'bigtext' ) echo '' . $args['name'] . ''; echo '
'; switch( $args['type'] ){ case 'text': case 'number': case 'password': $placeholder = $args['type'] == 'text' && !empty( $args['placeholder'] ) ? ' placeholder="' . esc_attr( $args['placeholder'] ) . '"' : ''; ?> value="" />
' . $args['unit'] . ''; ?>
'; ?> /> mpanel->name ) ) ); } $bigname = $args['id'] == 'export' || $args['id'] == 'import' ? 'mpanel-' . $args['id'] : 'mpanel[' . $args['id'] . ']'; $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . esc_attr( $args['placeholder'] ) . '"'; ?>
>
value="" /> '; $args_id = esc_attr( $args['id'] ); $args_type = esc_attr( $args['type'] ); foreach( $args['option'] as $key => $name ){ $id = esc_attr( $htmlid . '-' . $key ); printf( '', $id, $id, $args_id, $args_type, esc_attr( $key ), $option_value == $key ? ' checked="checked"' : '', $name ); } echo ''; foreach( array( 'show', 'hide', 'shows', 'hides' ) as $type ): if( empty( $args[$type] ) ) continue; $control_keys = array_intersect_key( $args[$type], $args['option'] ); $id_before = $type == 'show' || $type == 'hide' ? '#mpanel-panel-box-' : '.mpnael-group.'; foreach( $control_keys as $control_key => $control_value ){ if( empty( $control_value ) ) continue; $i = count( $control_value ); $controlhtmlid = ''; foreach( (array) $control_value as $id_after ){ $controlhtmlid .= $id_before . $id_after; if( $i !== 1 ) $controlhtmlid .= ','; --$i; } ?> '; if( !empty( $args['explain'] ) ) echo '

' . $args['explain'] . '

'; ?> menu = $this->default = array(); $this->page = $this->group = 0; $this->get_default = false; unset( $this->from ); } /** * 页面开始 */ public function before( $name, $class = '' ) { $this->menu[] = $name; ++$this->page; $classes = empty( $class ) ? '' : ' ' . $class; ?>

'; } /** * 选项组开始 */ public function group( $title, $class = '' ) { ++$this->group; $classes = empty( $class ) ? '' : ' ' . $class; ?>

'; } /** * 获取选项表单 * * @since Unknown * @since Beginning 4.0.5 用新的文件路径调用方式取代 `dirname( __FILE__ )`。 */ public function get_from( $reset = false ) { if ( !isset( $this->from ) || $reset ) { ob_start(); $filename = get_template_directory() . '/mpanel/mpanel-ui.php'; include( $filename ); $this->from = ob_get_clean(); } return $this->from; } /** * 获取默认设置 */ public function get_default() { $this->get_default = true; $this->get_from( true ); $default = $this->default; $this->init(); return $default; } } // End of page.