Plugin Directory

Changeset 543123


Ignore:
Timestamp:
05/11/2012 09:59:31 PM (14 years ago)
Author:
clintonb11
Message:
  • Moved division specific constants into their own file (and then ignored it)
  • All shared plugin code is now in connect.php
Location:
dell-cloud-connect/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dell-cloud-connect/trunk/.gitignore

    r543084 r543123  
    22node_modules
    33.DS_Store
     4plugin.php
  • dell-cloud-connect/trunk/connect.php

    r543121 r543123  
    11<?php
    2 /*
    3 Plugin Name: Dell Cloud Connect
    4 Plugin URI: http://marketing.dell.com/cloudcomputing-widget
    5 Description: Adds a widget to display the latest news and information from the most influential cloud computing blogs.
    6 Version: 0.2.0
    7 Author: Dell
    8 Author URI: http://www.dell.com
    9 
    10 
    11 Installing
    12 1. Copy cloud_connect folder to your plugins folder /wp-content/plugins/
    13 2. Activate it through the plugin management screen.
    14 3. Go to Appearance->Widgets and drag and drop the widget to wherever you want to show it.
    15 */
    16 
    172
    183// Define Actions
    194// ============================================
    205
    21 register_activation_hook(__FILE__,'edu_connect_install');
    22 register_deactivation_hook(__FILE__, 'edu_connect_uninstall');
    23 
    24 add_action( 'wp_print_scripts', 'edu_connect_scripts' );
    25 add_action( 'wp_print_styles', 'edu_connect_styles' );
    26 add_action( 'widgets_init', 'edu_connect_load_widgets' );
    27 add_action( 'admin_menu', 'edu_connect_admin_menu' );
    28 add_action( 'wp_ajax_edu_connect_showlink', 'edu_connect_admin_ajax_showlink' );
     6register_activation_hook(__FILE__,'dell_connect_install');
     7register_deactivation_hook(__FILE__, 'dell_connect_uninstall');
     8
     9add_action( 'wp_print_scripts', 'dell_connect_scripts' );
     10add_action( 'wp_print_styles', 'dell_connect_styles' );
     11add_action( 'widgets_init', 'dell_connect_load_widgets' );
     12add_action( 'admin_menu', 'dell_connect_admin_menu' );
     13add_action( 'wp_ajax_edu_connect_showlink', 'dell_connect_admin_ajax_showlink' );
    2914//add_action( 'admin_notices', 'edu_connect_admin_notice' );
    3015
     
    3318
    3419//Define Environment if not defined
    35 if(!defined('EDU_CONNECT_ENV')) {
    36     define('EDU_CONNECT_ENV', 'production');
    37 }
    38 define('EDU_PLUGIN_PATH', WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__)));
    39 define('EDU_PLUGIN_URL',  WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)));
    40 define('EDU_DIVISION', 'cloudcomputing');
     20if(!defined('DELL_CONNECT_ENV')) {
     21    define('DELL_CONNECT_ENV', 'production');
     22}
     23
     24define('DELL_CONNECT_PLUGIN_URL',  WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)));
     25
    4126
    4227//Define constants based on environment
    43 if(EDU_CONNECT_ENV == 'development') {
    44     define('EDU_CONNECT_SERVICE_URL','http://11.0.0.1:9001');
    45 }
    46 elseif (EDU_CONNECT_ENV == 'staging') {
    47     define('EDU_CONNECT_SERVICE_URL','http://staging.dell.system-11.com');
     28if(DELL_CONNECT_ENV == 'development') {
     29    define('DELL_CONNECT_SERVICE_URL','http://11.0.0.1:9001');
     30}
     31elseif (DELL_CONNECT_ENV == 'staging') {
     32    define('DELL_CONNECT_SERVICE_URL','http://staging.dell.system-11.com');
    4833}
    4934else {
    50     define('EDU_CONNECT_SERVICE_URL','http://dell.system-11.com');
     35    define('DELL_CONNECT_SERVICE_URL','http://dell.system-11.com');
    5136}
    5237
     
    5439 * Register the widget
    5540 */
    56 function edu_connect_load_widgets() {
     41function dell_connect_load_widgets() {
    5742    register_widget( 'Edu_Connect_Widget' );
    5843}
     
    6146 * Plugin Install/Activation Script
    6247 */
    63 function edu_connect_install() {
     48function dell_connect_install() {
    6449
    6550    //Check to make sure PHP config supports urls in file_get_contents
     
    7257       
    7358    //Set global default option
    74     $settings = file_get_contents(EDU_CONNECT_SERVICE_URL . '/client/add?division=' . EDU_DIVISION .'&url=' . urlencode(home_url()) . '&ajaxurl=' . urlencode(EDU_PLUGIN_URL . '/ajax.php') . '&clientid=' . $clientId);
     59    $settings = file_get_contents(DELL_CONNECT_SERVICE_URL . '/client/add?division=' . DELL_CONNECT_DIVISION .'&url=' . urlencode(home_url()) . '&ajaxurl=' . urlencode(DELL_CONNECT_PLUGIN_URL . '/ajax.php') . '&clientid=' . $clientId);
    7560    $settings = json_decode($settings);
    7661
    7762    if(!$settings->result) {
    78         file_get_contents(EDU_CONNECT_SERVICE_URL . '/client/error?url=' . urlencode(home_url()) . '&error=' . urlencode($settings->error));
     63        file_get_contents(DELL_CONNECT_SERVICE_URL . '/client/error?url=' . urlencode(home_url()) . '&error=' . urlencode($settings->error));
    7964        die("Sorry, there was a problem activating your blog. Please contact support+dell@system-11.com");
    8065    }
     
    8671}
    8772
    88 function edu_connect_uninstall() {
     73function dell_connect_uninstall() {
    8974    $clientId = get_option('edu_connect_clientid', null);
    90     $settings = file_get_contents(EDU_CONNECT_SERVICE_URL . '/client/deactivate?clientid=' . $clientId);
     75    $settings = file_get_contents(DELL_CONNECT_SERVICE_URL . '/client/deactivate?clientid=' . $clientId);
    9176    $settings = json_decode($settings);
    9277}
     
    10893        //Default data as constants
    10994       
    110         $this->url = EDU_CONNECT_SERVICE_URL . "/feed";
     95        $this->url = DELL_CONNECT_SERVICE_URL . "/feed";
    11196        //Set defaults
    11297        $widget_ops = array();
     
    194179        <script>
    195180            var _dec = _dec || [];
    196             <?php if(EDU_CONNECT_ENV == 'development' || EDU_CONNECT_ENV == 'staging'):?>
     181            <?php if(DELL_CONNECT_ENV == 'development' || DELL_CONNECT_ENV == 'staging'):?>
    197182            _dec.push(['enableDebug']);
    198183            <?php endif; ?>
    199             _dec.push(['setBaseUrl', '<?php echo EDU_CONNECT_SERVICE_URL ?>']);
     184            _dec.push(['setBaseUrl', '<?php echo DELL_CONNECT_SERVICE_URL ?>']);
    200185            _dec.push(['setClientId', '<?php echo get_option("edu_connect_clientid")?>']);
    201             _dec.push(['setDivision', '<?php echo EDU_DIVISION ?>']);
     186            _dec.push(['setDivision', '<?php echo DELL_CONNECT_DIVISION ?>']);
    202187            _dec.push(['getFeed',<?php echo (int)$count_items; ?>,<?php echo (($show_descriptions)?'true':'false'); ?>]);
    203188        </script>
     
    209194
    210195
    211 function edu_connect_scripts() {
     196function dell_connect_scripts() {
    212197    if (!is_admin()) {
    213         if(EDU_CONNECT_ENV == 'production') {
     198        if(DELL_CONNECT_ENV == 'production') {
    214199            wp_enqueue_script( $handle = 'edu_connect_ender', $src = 'https://s3.amazonaws.com/system11-dell/ender.min.js', array(), $ver = 1, $in_footer = false );
    215200            wp_enqueue_script( $handle = 'edu_connect_js', $src = 'https://s3.amazonaws.com/system11-dell/dell.min.js', array(), $ver = 1, $in_footer = false );
    216201        }
    217202         else {
    218             wp_enqueue_script( $handle = 'edu_connect_ender', $src = WP_PLUGIN_URL . '/edu-connect/assets/js/ender.js', array(), $ver = 1, $in_footer = false );
    219             wp_enqueue_script( $handle = 'edu_connect_js', $src = WP_PLUGIN_URL . '/edu-connect/assets/js/dell.js', array(), $ver = 1, $in_footer = false );
     203            wp_enqueue_script( $handle = 'edu_connect_ender', $src = DELL_CONNECT_PLUGIN_URL . '/assets/js/ender.js', array(), $ver = 1, $in_footer = false );
     204            wp_enqueue_script( $handle = 'edu_connect_js', $src = DELL_CONNECT_PLUGIN_URL . '/assets/js/dell.js', array(), $ver = 1, $in_footer = false );
    220205        }
    221206    }
    222207}
    223208
    224 function edu_connect_styles() {
     209function dell_connect_styles() {
    225210    if (!is_admin()) {
    226         wp_enqueue_style( $handle = 'edu_connect_css', $src = WP_PLUGIN_URL . '/edu-connect/assets/css/styles.css', array(), $ver = 1 );
     211        wp_enqueue_style( $handle = 'edu_connect_css', $src = DELL_CONNECT_PLUGIN_URL . '/edu-connect/assets/css/styles.css', array(), $ver = 1 );
    227212    }
    228213}
     
    236221}
    237222
    238 function edu_connect_admin_menu() {
     223function dell_connect_admin_menu() {
    239224    //add_menu_page( 'Dell Services', 'Dell Services', 'manage_options', 'dell-services', null, WP_PLUGIN_URL . '/edu-connect/assets/img/dellecomicon.png', null );
    240225    //$dell_news_page = add_submenu_page( 'dell-services', 'News', 'News', 'manage_options', 'dell-news', 'dell_admin_page' );
    241     $edu_connect_page = add_options_page('Dell Cloud Connect', 'Dell Cloud Connect', 'manage_options', 'edu-connect', 'edu_connect_admin_page' );
     226    $edu_connect_page = add_options_page('<?php echo DELL_CONNECT_PLUGIN_NAME ?>', '<?php echo DELL_CONNECT_PLUGIN_NAME ?>', 'manage_options', 'edu-connect', 'edu_connect_admin_page' );
    242227    remove_submenu_page( 'dell-services', 'dell-services' );
    243228
     
    246231
    247232function edu_connect_admin_scripts() {
    248     wp_enqueue_style( $handle = 'edu_connect_admin_css', $src = WP_PLUGIN_URL . '/edu-connect/assets/css/admin-styles.css', array(), $ver = 1 );
     233    wp_enqueue_style( $handle = 'edu_connect_admin_css', $src = DELL_CONNECT_PLUGIN_URL . '/assets/css/admin-styles.css', array(), $ver = 1 );
    249234    wp_enqueue_script( 'jquery-ui-core' );
    250235    wp_enqueue_script( 'jquery-ui-tabs' );
    251     wp_enqueue_script( $handle = 'edu_connect_plugins', $src = WP_PLUGIN_URL . '/edu-connect/assets/js/plugins.js', array(), $ver = 1, $in_footer = false );
     236    wp_enqueue_script( $handle = 'edu_connect_plugins', $src = DELL_CONNECT_PLUGIN_URL . '/assets/js/plugins.js', array(), $ver = 1, $in_footer = false );
    252237   
    253     if(EDU_CONNECT_ENV == 'production') {
     238    if(DELL_CONNECT_ENV == 'production') {
    254239        wp_enqueue_script( $handle = 'edu_connect_ender', $src = 'https://s3.amazonaws.com/system11-dell/ender.min.js', array(), $ver = 1, $in_footer = false );
    255240            wp_enqueue_script( $handle = 'edu_connect_js', $src = 'https://s3.amazonaws.com/system11-dell/dell.min.js', array(), $ver = 1, $in_footer = false );
    256241    }
    257242    else {
    258         wp_enqueue_script( $handle = 'edu_connect_ender', $src = WP_PLUGIN_URL . '/edu-connect/assets/js/ender.js', array(), $ver = 1, $in_footer = false );
    259         wp_enqueue_script( $handle = 'edu_connect_js', $src = WP_PLUGIN_URL . '/edu-connect/assets/js/dell.js', array(), $ver = 1, $in_footer = false );
     243        wp_enqueue_script( $handle = 'edu_connect_ender', $src = DELL_CONNECT_PLUGIN_URL . '/assets/js/ender.js', array(), $ver = 1, $in_footer = false );
     244        wp_enqueue_script( $handle = 'edu_connect_js', $src = DELL_CONNECT_PLUGIN_URL . '/assets/js/dell.js', array(), $ver = 1, $in_footer = false );
    260245    }
    261246   
     
    271256<div class="wrap">
    272257<div id="icon-options-general" class="icon32"><br></div>
    273 <h2>Dell Cloud Connect Settings</h2>
     258<h2><?php echo DELL_CONNECT_PLUGIN_NAME ?></h2>
    274259<div id="tabs">
    275260    <h2 class="nav-tab-wrapper">
     
    289274        <script>
    290275            var _dec = _dec || [];
    291             <?php if(EDU_CONNECT_ENV == 'development' || EDU_CONNECT_ENV == 'staging'):?>
     276            <?php if(DELL_CONNECT_ENV == 'development' || DELL_CONNECT_ENV == 'staging'):?>
    292277            _dec.push(['enableDebug']);
    293278            <?php endif; ?>
    294             _dec.push(['setBaseUrl', '<?php echo EDU_CONNECT_SERVICE_URL ?>']);
     279            _dec.push(['setBaseUrl', '<?php echo DELL_CONNECT_SERVICE_URL ?>']);
    295280            _dec.push(['setClientId', '<?php echo get_option("edu_connect_clientid")?>']);
    296             _dec.push(['setDivision', '<?php echo EDU_DIVISION ?>']);
     281            _dec.push(['setDivision', '<?php echo DELL_CONNECT_DIVISION ?>']);
    297282            _dec.push(['getBlogList']);
    298283        </script>
     
    327312}
    328313
    329 function edu_connect_admin_ajax_showlink() {
     314function dell_connect_admin_ajax_showlink() {
    330315    global $wpdb;
    331316    $showSponsoredLink = isset($_POST['backlinkActive'])?true:false;
Note: See TracChangeset for help on using the changeset viewer.