text_domain = $text_domain; /** * Update Status * * "ok" : Successful update */ $status = ""; /** DB Connect */ $db = new add_Banner_Extension_Admin_Db(); /** Set Default Parameter for Array */ $options = array( "id" => "", "image_url" => "", "image_alt" => "", "link_url" => "", "open_new_tab" => 0, "insert_element_class" => "", "insert_element_id" => "", "how_display" => "article", "filter_category" => 0, "category_id" => 0 ); /** Key Set */ if ( isset( $_GET['add_banner_extension_id'] ) && is_numeric( $_GET['add_banner_extension_id'] ) ) { $options['id'] = esc_html( $_GET['add_banner_extension_id'] ); } /** DataBase Update & Insert Mode */ if ( isset( $_POST['add_banner_extension_id'] ) && is_numeric( $_POST['add_banner_extension_id'] ) ) { $db->update_options( $_POST ); $options['id'] = $_POST['add_banner_extension_id']; $status = "ok"; } else { if ( isset( $_POST['add_banner_extension_id'] ) && $_POST['add_banner_extension_id'] === '' ) { $options['id'] = $db->insert_options( $_POST ); $status = "ok"; } } /** Mode Judgment */ if ( isset( $options['id'] ) && is_numeric( $options['id'] ) ) { $options = $db->get_options( $options['id'] ); } $this->page_render( $options, $status ); } /** * Page Render. * * @param array $options * @param string $status */ private function page_render ( $options, $status ) { $html = ''; $html .= '
'; $html .= '

' . __( 'Edit Banner', $this->text_domain ) . '

'; echo $html; switch ( $status ) { case "ok": $this->information_render(); break; default: break; } $html = '
'; $html .= ''; $html .= '

' . __( 'Banner Setting', $this->text_domain ) . '

'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; echo $html; $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
'; if ( !empty( $options['image_url'] ) ) { $html .= ''; } else { $html .= ''; } $html .= ''; $html .= ''; $html .= '
'; $html .= ''; $html .= '

' . __( 'Enter the text of alt attribute.', $this->text_domain ) . '

'; $html .= '
'; $html .= ''; $html .= '

' . __( 'You can set a link to the image if you enter url.', $this->text_domain ) . '

'; $html .= '
'; $html .= ''; $html .= '

' . __( 'You can add the class(es) in the banner image. "class=" is unnecessary.', $this->text_domain ) . '
' . __( 'Separate them with a One-byte space, if you want to set multiple.', $this->text_domain ) . '

'; $html .= '
'; $html .= ''; $html .= '

' . __( 'You can add the id in the banner image. "id=" is unnecessary.', $this->text_domain ) . '

'; $html .= '
'; $html .= '

' . __( 'Display Setting', $this->text_domain ) . '

'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; $html .= ''; if ( isset( $options['id'] ) && is_numeric( $options['id'] ) ) { $html .= ''; } $html .= '
'; $html .= '
'; echo $html; $args = array( 'name' => 'banner-display-category', 'id' => 'banner-display-category', 'selected' => $options['category_id'], 'hierarchical' => 1 ); wp_dropdown_categories( $args ); $html = '

' . __( 'Images are displayed only when the selected category are attached to the post.', $this->text_domain ) . '

'; $html .= '
'; echo $html; submit_button(); $html = '
'; $html .= '
'; echo $html; require_once ( plugin_dir_path( __FILE__ ) . 'add-banner-admin-upload.php' ); } /** * Information Message Render * * @since 1.0.0 */ private function information_render () { $html = '
'; $html .= '

' . __( 'Add Banner Extension Information Update.', $this->text_domain ) . '

'; $html .= ''; $html .= '
'; echo $html; } }