SHARE
TWEET

plugin example

merlin867 Feb 12th, 2014 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. include_once('PriceCompareV2_LifeCycle.php');
  5.  
  6. class PriceCompareV2_Plugin extends PriceCompareV2_LifeCycle {
  7.  
  8.     /**
  9.      * See: http://plugin.michael-simpson.com/?page_id=31
  10.      * @return array of option meta data.
  11.      */
  12.     public function getOptionMetaData() {
  13.         //  http://plugin.michael-simpson.com/?page_id=31
  14.         return array(
  15.             //'_version' => array('Installed Version'), // Leave this one commented-out. Uncomment to test upgrades.
  16.             'ATextInput' => array(__('Enter in some text', 'my-awesome-plugin')),
  17.             'Donated' => array(__('I have donated to this plugin', 'my-awesome-plugin'), 'false', 'true'),
  18.             'CanSeeSubmitData' => array(__('Can See Submission data', 'my-awesome-plugin'),
  19.                                         'Administrator', 'Editor', 'Author', 'Contributor', 'Subscriber', 'Anyone')
  20.         );
  21.     }
  22.  
  23. //    protected function getOptionValueI18nString($optionValue) {
  24. //        $i18nValue = parent::getOptionValueI18nString($optionValue);
  25. //        return $i18nValue;
  26. //    }
  27.  
  28.     protected function initOptions() {
  29.         $options = $this->getOptionMetaData();
  30.         if (!empty($options)) {
  31.             foreach ($options as $key => $arr) {
  32.                 if (is_array($arr) && count($arr > 1)) {
  33.                     $this->addOption($key, $arr[1]);
  34.                 }
  35.             }
  36.         }
  37.     }
  38.  
  39.     public function getPluginDisplayName() {
  40.         return 'Price Compare V2';
  41.     }
  42.  
  43.     protected function getMainPluginFileName() {
  44.         return 'price-compare-v2.php';
  45.     }
  46.  
  47.     /**
  48.      * See: http://plugin.michael-simpson.com/?page_id=101
  49.      * Called by install() to create any database tables if needed.
  50.      * Best Practice:
  51.      * (1) Prefix all table names with $wpdb->prefix
  52.      * (2) make table names lower case only
  53.      * @return void
  54.      */
  55.     protected function installDatabaseTables() {
  56.         //        global $wpdb;
  57.         //        $tableName = $this->prefixTableName('mytable');
  58.         //        $wpdb->query("CREATE TABLE IF NOT EXISTS `$tableName` (
  59.         //            `id` INTEGER NOT NULL");
  60.     }
  61.  
  62.     /**
  63.      * See: http://plugin.michael-simpson.com/?page_id=101
  64.      * Drop plugin-created tables on uninstall.
  65.      * @return void
  66.      */
  67.     protected function unInstallDatabaseTables() {
  68.         //        global $wpdb;
  69.         //        $tableName = $this->prefixTableName('mytable');
  70.         //        $wpdb->query("DROP TABLE IF EXISTS `$tableName`");
  71.     }
  72.  
  73.  
  74.     /**
  75.      * Perform actions when upgrading from version X to version Y
  76.      * See: http://plugin.michael-simpson.com/?page_id=35
  77.      * @return void
  78.      */
  79.     public function upgrade() {
  80.     }
  81.  
  82.     public function addActionsAndFilters() {
  83.  
  84.         // Add options administration page
  85.         // http://plugin.michael-simpson.com/?page_id=47
  86.         add_action('admin_menu', array(&$this, 'addSettingsSubMenuPage'));
  87.  
  88.         // Example adding a script & style just for the options administration page
  89.         // http://plugin.michael-simpson.com/?page_id=47
  90.         //        if (strpos($_SERVER['REQUEST_URI'], $this->getSettingsSlug()) !== false) {
  91.         //            wp_enqueue_script('my-script', plugins_url('/js/my-script.js', __FILE__));
  92.         //            wp_enqueue_style('my-style', plugins_url('/css/my-style.css', __FILE__));
  93.         //        }
  94.         if (strpos($_SERVER['REQUEST_URI'], $this->getSettingsSlug()) !== false) {
  95.                 wp_enqueue_style('jquery-ui', plugins_url('/css/jquery-ui-1.10.4.custom.css', __FILE__));
  96.                 wp_enqueue_script('jquery-ui-core');
  97.                 wp_enqueue_script('jquery-ui-tabs');
  98.                 // enqueue any othere scripts/styles you need to use
  99.         }
  100.  
  101.  
  102.         // Add Actions & Filters
  103.         // http://plugin.michael-simpson.com/?page_id=37
  104.  
  105.  
  106.         // Adding scripts & styles to all pages
  107.         // Examples:
  108.         //        wp_enqueue_script('jquery');
  109.         //        wp_enqueue_style('my-style', plugins_url('/css/my-style.css', __FILE__));
  110.         //        wp_enqueue_script('my-script', plugins_url('/js/my-script.js', __FILE__));
  111.  
  112.  
  113.         // Register short codes
  114.         // http://plugin.michael-simpson.com/?page_id=39
  115.  
  116.  
  117.         // Register AJAX hooks
  118.         // http://plugin.michael-simpson.com/?page_id=41
  119.  
  120.     }
  121.  
  122.  
  123. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top