Ank Prism For WP plugin.')); } class Ank_Prism_For_WP_Admin { function __construct() { /*save setting upon plugin activation*/ register_activation_hook(plugin_basename(APFW_BASE_FILE), array($this, 'apfw_init_settings')); /* Add settings link under admin settings */ add_action('admin_menu', array($this, 'apfw_settings_menu')); /* Add settings link to plugin list page */ add_filter('plugin_action_links_' . plugin_basename(APFW_BASE_FILE), array($this, 'apfw_plugin_actions_links'), 10, 2); //add a button to mce editor //source: https://www.gavick.com/blog/wordpress-tinymce-custom-buttons/ add_action('admin_head', array($this, 'apfw_add_editor_button')); add_action('admin_print_scripts', array($this, 'apfw_admin_inline_script'), 10); add_action('admin_print_styles', array($this, 'apfw_admin_inline_style'), 99); } //end constructor function apfw_init_settings() { /* if settings exists then return early */ if (get_option(APFW_OPTION_NAME)) { return; } //default settings $new_options = array( 'plugin_ver' => APFW_PLUGIN_VERSION, 'theme' => 1, 'lang' => array(1, 2, 3), 'plugin' => array(4), 'onlyOnPost' => 0, 'noAssistant' => 0, ); add_option(APFW_OPTION_NAME, $new_options); } function apfw_settings_menu() { $page_hook_suffix = add_submenu_page('options-general.php', '▲ Ank Prism For WP', 'Ank Prism For WP', 'manage_options', APFW_PLUGIN_SLUG, array($this, 'APFW_Option_Page')); /* add help drop down menu on option page wp v3.3+ */ add_action("load-$page_hook_suffix", array($this, 'apfw_help_menu_tab')); } private function apfw_settings_page_url() { return add_query_arg('page', APFW_PLUGIN_SLUG, 'options-general.php'); } function apfw_plugin_actions_links($links) { if (current_user_can('manage_options')) { array_unshift( $links, sprintf('%s', esc_attr($this->apfw_settings_page_url()), __('Settings')) ); } return $links; } function APFW_Option_Page() { $options = get_option('ank_prism_for_wp'); global $Ank_Prism_For_WP_Obj; if (isset($_POST['save_apfw_form'])) { /* WP inbuilt form security check */ check_admin_referer('apfw_form', '_wpnonce-apfw_form'); $options['plugin_ver'] = APFW_PLUGIN_VERSION; if (isset($_POST['ptheme'])) { $options['theme'] = intval($_POST['ptheme']); } else { $options['theme'] = 1; } if (isset($_POST['plang'])) { $options['lang'] = $_POST['plang']; } else { $options['lang'] = array(); } if (isset($_POST['pplugin'])) { $options['plugin'] = $_POST['pplugin']; } else { $options['plugin'] = array(); } $options['onlyOnPost'] = (isset($_POST['onlyOnPost'])) ? 1 : 0; $options['noAssistant'] = (isset($_POST['noAssistant'])) ? 1 : 0; //save back to database update_option('ank_prism_for_wp', $options); echo "

Your settings has been saved.

"; //delete js and css files $this->delete_file('prism-css.css'); $this->delete_file('prism-js.js'); /* Detect if cache is enabled and warn user to flush cache */ if (WP_CACHE) { echo "
It seems that a caching/performance plugin is active on this site. Please manually invalidate/flush that plugin cache to reflect the settings you saved here.
"; } }//end if isset post ?>

Ank Prism For WP (v)

Select a Theme

apfw_theme_list(); for ($i = 1; $i <= count($theme_list); $i++) { echo ''; echo '"; echo ' Preview
'; } ?>

Select Languages

apfw_lang_list(); for ($i = 1; $i <= count($lang_list); $i++) { echo ''; echo '"; echo ($lang_list[$i]['require'] !== '') ? ' (Requires: ' . $lang_list[$i]['require'] . ')' : ''; echo '
'; } ?>

Select Plugins

apfw_plugin_list(); for ($i = 1; $i <= count($plugin_list); $i++) { echo ''; echo '"; echo ' View Demo
'; } ?>

> >


Created with ♥ by Ankur Kumar | View Original Site for Demos and Instructions | Fork on GitHub

Showing Debugging Info:
'; var_dump($options); echo '


'; }?>
add_help_tab( array( 'id' => 'apfw-overview', 'title' => 'Overview', 'content' => '

Thanks for using "Ank Prism For WP"
' . 'This plugin allows you to control and use Prism Syntax Highlighter on your website. Just configure options below and ' . 'save your settings.Then use something like this in your posts.' . '<pre><code class="language-css">p { color: red }</code></pre>' . '
You can also use in editor Prism Assistant Button.

' ) ); $curr_screen->add_help_tab( array( 'id' => 'apfw-troubleshoot', 'title' => 'Troubleshoot', 'content' => '

Things to remember' . '

' ) ); $curr_screen->add_help_tab( array( 'id' => 'apfw-more-info', 'title' => 'More', 'content' => '

Need more information ?
' . 'A brief FAQ is available here
' . 'You can also check out instructions from original developer here .
' . 'Support is only available on WordPress Forums, click here to ask anything about this plugin.
' . 'You can also report a bug at plugin's GitHub page.' . ' I will try to reply as soon as possible.

' ) ); /*help sidebar links */ $curr_screen->set_help_sidebar( '

Quick Links

' . '

Plugin FAQ

' . '

Plugin Home

' ); } public function apfw_add_editor_button() { if ($this->apfw_check_if_btn_can_be() == true) { add_filter("mce_external_plugins", array($this, "afpw_add_tinymce_plugin")); add_filter('mce_buttons', array($this, 'afpw_register_tinymce_button')); } } function afpw_register_tinymce_button($buttons) { array_push($buttons, "afpw_assist_button"); return $buttons; } function afpw_add_tinymce_plugin($plugin_array) { $plugin_array['afpw_assist_button'] = plugins_url('/apfw-editor-plugin.min.js', APFW_BASE_FILE); return $plugin_array; } function apfw_admin_inline_script($hook) { if ($this->apfw_check_if_btn_can_be() == true) { global $Ank_Prism_For_WP_Obj; $lang_list = $Ank_Prism_For_WP_Obj->apfw_lang_list(); echo ""; } } function apfw_admin_inline_style($hook) { if ($this->apfw_check_if_btn_can_be() == true) { ?>