/** * Setup the help tabs and sidebar. * * @since Post Snippets 1.8.9 */ public function addHelpTabs() { $screen = get_current_screen(); $screen->set_help_sidebar($this->helpSidebar()); $screen->add_help_tab( array( 'id' => 'basic-plugin-help', 'title' => __('Basic', PostSnippets::TEXT_DOMAIN), 'content' => $this->helpBasic() ) ); $screen->add_help_tab( array( 'id' => 'shortcode-plugin-help', 'title' => __('Shortcode', PostSnippets::TEXT_DOMAIN), 'content' => $this->helpShortcode() ) ); if (PostSnippets::canExecutePHP()) { $screen->add_help_tab( array( 'id' => 'php-plugin-help', 'title' => __('PHP', PostSnippets::TEXT_DOMAIN), 'content' => $this->helpPhp() ) ); } $screen->add_help_tab( array( 'id' => 'advanced-plugin-help', 'title' => __('Advanced', PostSnippets::TEXT_DOMAIN), 'content' => $this->helpAdvanced() ) ); }
<tr class='recent'> <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='<?php echo $key; ?>' /></th> <td class='row-title'> <input type='text' name='<?php echo $key; ?>_title' value='<?php echo $snippet['title']; ?>' /> </td> <td class='name'> <input type='text' name='<?php echo $key; ?>_vars' value='<?php echo $snippet['vars']; ?>' /> <br/> <br/> <?php PostSnippets_Admin::checkbox(__('Shortcode', PostSnippets::TEXT_DOMAIN), $key.'_shortcode', $snippet['shortcode']); echo '<br/><strong>Shortcode Options:</strong><br/>'; if (PostSnippets::canExecutePHP()) { PostSnippets_Admin::checkbox( __('PHP Code', PostSnippets::TEXT_DOMAIN), $key.'_php', $snippet['php'] ); } $wptexturize = isset( $snippet['wptexturize'] ) ? $snippet['wptexturize'] : false; PostSnippets_Admin::checkbox('wptexturize', $key.'_wptexturize', $wptexturize); ?> </td> <td class='desc'> <textarea name="<?php echo $key; ?>_snippet" class="large-text" style='width: 100%;' rows="5"><?php echo htmlspecialchars($snippet['snippet'], ENT_NOQUOTES); ?></textarea> <?php _e( 'Description', PostSnippets::TEXT_DOMAIN ) ?>: <input type='text' style='width: 100%;' name='<?php echo $key; ?>_description' value='<?php if (isset( $snippet['description'] ) ) echo esc_html($snippet['description']); ?>' /><br/>
/** * Update Snippet/s. */ private function update() { if (isset($_POST['update-snippets']) && isset($_POST['update_snippets_nonce']) && wp_verify_nonce($_POST['update_snippets_nonce'], 'update_snippets') ) { $snippets = get_option(PostSnippets::OPTION_KEY); if (!empty($snippets)) { foreach ($snippets as $key => $value) { $new_snippets[$key]['title'] = trim($_POST[$key.'_title']); $new_snippets[$key]['vars'] = str_replace(' ', '', trim($_POST[$key.'_vars'])); $new_snippets[$key]['shortcode'] = isset($_POST[$key.'_shortcode']) ? true : false; if (PostSnippets::canExecutePHP()) { $new_snippets[$key]['php'] = isset($_POST[$key.'_php']) ? true : false; } else { $new_snippets[$key]['php'] = isset($snippets[$key]['php']) ? $snippets[$key]['php'] : false; } $new_snippets[$key]['wptexturize'] = isset($_POST[$key.'_wptexturize']) ? true : false; $new_snippets[$key]['snippet'] = wp_specialchars_decode(trim(stripslashes($_POST[$key.'_snippet'])), ENT_NOQUOTES); $new_snippets[$key]['description'] = wp_specialchars_decode(trim(stripslashes($_POST[$key.'_description'])), ENT_NOQUOTES); } update_option(PostSnippets::OPTION_KEY, $new_snippets); $this->message(__('Snippets have been updated.', PostSnippets::TEXT_DOMAIN)); } } }