$data['warnings'] = Phpsnippets\Base::get_value($ps_data, 'warnings', array()); $data['snippet_suffix'] = Phpsnippets\Base::get_value($ps_data, 'snippet_suffix'); $data['show_builtin_snippets'] = Phpsnippets\Base::get_value($ps_data, 'show_builtin_snippets'); $data['show_tmce_button'] = Phpsnippets\Base::get_value($ps_data, 'show_tmce_button'); // Save if submitted... if (!empty($_POST) && check_admin_referer($data['action_name'], $data['nonce_name'])) { if (isset($_POST['activate_license'])) { if (PhpSnippets\License::activate($_POST['license_key'])) { $data['msg'] .= sprintf('<div class="updated"><p>%s</p></div>', 'Your license has been successfully activated. Thank you for your support!'); ob_start(); PhpSnippets\License::get_fields(); $data['licensing_fields'] = ob_get_clean(); } else { $data['msg'] .= sprintf('<div class="error"><p>%s</p></div>', 'There was a problem activating your license. Sorry for the inconvenience.'); ob_start(); PhpSnippets\License::get_fields(); $data['licensing_fields'] = ob_get_clean(); } // options-general.php?page=php-snippets //print '<script type="text/javascript">window.location.replace("'.get_admin_url(false, 'options-general.php?page=php-snippets').'");</script>'; } else { // A little cleanup before we handoff to save_definition_filter $snippet_dirs = Phpsnippets\Base::get_value($_POST, 'snippet_dirs', array()); $snippet_suffix = Phpsnippets\Base::get_value($_POST, 'snippet_suffix'); $show_builtin_snippets = Phpsnippets\Base::get_value($_POST, 'show_builtin_snippets'); $show_tmce_button = Phpsnippets\Base::get_value($_POST, 'show_tmce_button'); $snippet_suffix = !empty($snippet_suffix) ? trim(strip_tags($snippet_suffix)) : '.snippet.php'; foreach ($snippet_dirs as $i => $dir) { // remove empty val if (trim($dir) == '') { unset($snippet_dirs[$i]);
exit('No direct script access allowed'); } //------------------------------------------------------------------------------ //! Load up! // plugin_dir_path(__FILE__) //------------------------------------------------------------------------------ require_once PHP_SNIPPETS_PATH . '/includes/Base.php'; require_once PHP_SNIPPETS_PATH . '/includes/License.php'; $php_license = PhpSnippets\License::check(); $php_snippets_data = get_option('php_snippets'); // Check the license, show an error add_action('admin_notices', function () { global $php_license; // Don't show this when we're posting data if ($php_license != 'valid' && empty($_POST)) { print PhpSnippets\License::get_error_msg(); } }); if ($php_license != 'valid') { return; } require_once PHP_SNIPPETS_PATH . '/includes/Snippet.php'; require_once PHP_SNIPPETS_PATH . '/includes/Ajax.php'; require_once PHP_SNIPPETS_PATH . '/includes/Widget.php'; if ($php_snippets_data['show_tmce_button'] == 1) { add_filter('mce_external_plugins', function ($plugin_array) { $url = PHP_SNIPPETS_URL . '/js/editor_plugin.js'; $plugin_array['php_snippets'] = $url; return $plugin_array; }); }