array('compact-1' => 'Compact 1', 'compact-2' => 'Compact 2', 'common-1' => 'Common 1', 'full' => 'Full' ), 'lang-list' => array('compact-1' => array ( 'php' => 'PHP', 'xml' => 'XML / HTML', 'css' => 'CSS', 'javascript' => 'Javascript', 'sass' => 'SASS', 'sql' => 'SQL', 'plain' => 'SH Plain', 'adddarkplain' => 'Dark Plain (Console)', 'addlightplain' => 'Light Plain' ), 'compact-2' => array ('java' => 'Java', 'bash' => 'Bash', 'ruby' => 'Ruby', 'python' => 'Python', 'cpp' => 'C++', 'csharp' => 'C#', 'perl' => 'Perl', 'sql' => 'SQL', 'plain' => 'SH Plain', 'adddarkplain' => 'Dark Plain (Console)', 'addlightplain' => 'Light Plain' ), 'common-1' => array( 'php' => 'PHP', 'xml' => 'XML / HTML', 'css' => 'CSS', 'javascript' => 'Javascript', 'sass' => 'SASS', 'java' => 'Java', 'bash' => 'Bash', 'ruby' => 'Ruby', 'python' => 'Python', 'cpp' => 'C++', 'csharp' => 'C#', 'perl' => 'Perl', 'sql' => 'SQL', 'diff' => 'Diff', 'plain' => 'SH Plain', 'adddarkplain' => 'Dark Plain (Console)', 'addlightplain' => 'Light Plain' ), 'full' => array( 'php' => 'PHP', 'xml' => 'XML / HTML', 'css' => 'CSS', 'javascript' => 'Javascript', 'sass' => 'SASS', 'java' => 'Java', 'bash' => 'Bash', 'ruby' => 'Ruby', 'python' => 'Python', 'cpp' => 'C++', 'csharp' => 'C#', 'perl' => 'Perl', 'vb' => 'VB', 'poweshell' => 'Power Shell', 'typescript' => 'Typescript', 'tap' => 'Tap', 'swift' => 'Swift', 'scala' => 'Scala', 'javafx' => 'Java FX', 'haxe' => 'Haxe', 'groovy' => 'Groovy', 'erlang' => 'Erlang', 'delphi' => 'Delphi', 'coldfushion' => 'Coldfushion', 'as3' => 'Action Script 3', 'applescript' => 'Applescript', 'base' => 'Base', 'sql' => 'SQL', 'diff' => 'Diff', 'plain' => 'SH Plain', 'adddarkplain' => 'Dark Plain (Console)', 'addlightplain' => 'Light Plain' ), ), 'themes' => array( 'default' => 'Default', 'django' => 'Django', 'eclipse' => 'Eclipse', 'emacs' => 'EMACS', 'fadetogrey' => 'Fade to Grey', 'mdultra' => 'MDUltra', 'midnight' => 'Midnight', 'rdark' => 'RDark', 'swift' => 'Swift' ) ); /** * Default options, we use dash instead of undercore, because we'll use this * in the foreach loop at aphms-front.php */ private $data_options = array ('lang-pack' => 'compact-1', 'default-lang' => 'php', 'theme' => 'default', 'gutter' => 1, 'start-number' => 1, 'auto-links' => 1, 'collapse' => 0, 'class' => '', 'smart-tabs' => 1, 'tab-size' => 4, 'title' => '', 'font-size' => 'default', 'max-height' => '480', 'add-css' => 0, 'add-css-value' => '', 'token' => '1470914799' ); private $admin_notice; public function __construct() { $this->admin_notices = new Aphsh_Admin_Notices; $this->options = get_option( APHSH_OPTION, array() ); if (!$this->options) { update_option(APHSH_OPTION, $this->data_options); } register_activation_hook ( APHSH_PLUGIN_PATH . APHSH_DS . APHSH_PLUGIN_FILE_NAME, array($this, 'activate_plugin') ); add_action( 'admin_init', array( $this, 'page_init' ) ); add_action( 'admin_head', array( $this, 'print_style') ); add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_filter( 'plugin_action_links', array($this, 'action_link'), 10, 5); add_action( 'admin_enqueue_scripts', array($this, 'register_scripts') ); add_action( 'updated_option', array($this, 'update_files'), 1); // add_action( 'admin_notices', array( $this, 'adminNotices' ), 1 ); add_action( 'plugins_loaded', array($this, 'check_update') ); // AJAX add_action( 'wp_ajax_nopriv_aphsh-dismiss-notice' , array( $this , 'ajax_no_priv' ) ); add_action( 'wp_ajax_aphsh-dismiss-notice', array($this, 'ajax_dismiss_notice') ); } public function ajax_no_priv() { // echo 'xxx'; die; } // When the close button is clicked public function ajax_dismiss_notice() { $check = wp_verify_nonce($_POST['nonce'], 'aphsh-admin-all'); if ($check) { $this->admin_notices->delete_notice($_POST['msg']); } wp_send_json_success( array( 'msg' => 'success', 'check' => $check ) ); } public function update_files() { $obj = new Aphsh_Build(); $obj->build_files(); } public function activate_plugin() { if (!$this->options) { update_option(APHSH_OPTION, $this->data_options); update_option(APHSH_OPTION_VERSION, APHSH_PLUGIN_VERSION); update_option(APHSH_OPTION_SHDATA, $this->default_param); } } public function check_update() { $plugin_option_version = get_option( APHSH_OPTION_VERSION, '0' ); // $plugin_option_version = '0'; if (version_compare(APHSH_PLUGIN_VERSION, $plugin_option_version) > 0) { update_option(APHSH_OPTION_VERSION, APHSH_PLUGIN_VERSION); update_option(APHSH_OPTION_SHDATA, $this->default_param); if (!$plugin_option_version || $plugin_option_version < 1.2) { $msg = 'APH SYNTAX HIGHLIGHTER v' . APHSH_PLUGIN_VERSION . ' Language added: Dark Plain (Console Style) and Light Plain'; $this->admin_notices->add_notice($msg, 'success', false, true); } } } public function register_scripts($hook) { if ($hook == 'settings_page_'.APHSH_PLUGIN_DIR_NAME) { wp_enqueue_style('aphsh-style', APHSH_PLUGIN_URL . '/css/aphsh-admin.css?rand='.time(), '', APHSH_PLUGIN_VERSION); wp_enqueue_script('aphsh-admin', APHSH_PLUGIN_URL . '/js/aphsh-admin.js?rand='.time(), '', APHSH_PLUGIN_VERSION); wp_enqueue_script('aphsh-taboverride', APHSH_PLUGIN_URL . '/js/taboverride/taboverride.min.js', '', APHSH_PLUGIN_VERSION); } wp_enqueue_script('aphsh-admin-all', APHSH_PLUGIN_URL . '/js/aphsh-admin-all.js?rand='.time(), '', APHSH_PLUGIN_VERSION); wp_localize_script ( 'aphsh-admin-all', 'aphsh', array( 'nonce' => wp_create_nonce('aphsh-admin-all'), 'ajaxurl' => admin_url('admin-ajax.php') ) ); } /** * Add Settings ling to plugin list Settings | Deactivate | Edit */ public function action_link($links, $file) { static $plugin; if (!isset($plugin)) $plugin = APHSH_PLUGIN_DIR_NAME . '/' . APHSH_PLUGIN_FILE_NAME; if ($plugin == $file) { $setting_link = 'Settings'; array_unshift($links, $setting_link); } return $links; } public function print_style() { echo ''; } /** * Add options page */ public function add_plugin_page() { $page_title = 'APH Syntax Highlighter Options'; $menu_title = 'Syntax Highlighter'; $url = 'aph-syntax-highlighter'; add_options_page( $page_title, $menu_title, 'manage_options', $url, array( $this, 'admin_setting_page' ) ); } public function admin_setting_page() { // echo '
'; print_r($this->options); ?>default_param['lang-pack']; echo ''; echo 'Options
APH Syntax Highlighter Options
Since syntax highlighter 4 do not support dynamically load brushes, so we need to build it at first. In order not to bloat the file size, we sparate the bruses'; echo '
Default language in the code editor\'s drop down menu
'; // Other list of language, hidden, displayed when the language pack changed; echo ' '; } public function option_theme_list() { $theme_list = $this->default_param['themes']; $options = ''; return $options; } public function option_plugin_options() { $options = $this->options['options']; ?>
data_options; } else { foreach ($this->options as $key => $val) { if (!key_exists($key, $inputs)) { $inputs[$key] = 0; } } } return $inputs; } } ?>