Plugin Directory

Changeset 944671


Ignore:
Timestamp:
07/08/2014 03:59:59 AM (12 years ago)
Author:
dylanemoore
Message:

Adding version 1.02 of sendwithus plugin

Location:
sendwithus/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sendwithus/trunk/inc/helper_functions.php

    r934659 r944671  
    1919function set_globals(){
    2020    $GLOBALS['templates'] = get_templates();
    21     $GLOBALS['api_key'] = get_api_key();
    2221}
    2322
    2423// Function for creating a default template if there isn't one already (Single Site Instance)
    2524function create_default_template(){
    26     $active_templates = get_templates();
     25    $active_templates = $GLOBALS['templates'];
    2726
    2827    $api_key = get_option('api_key');
     
    6059// Function for creating a default template if there isn't one already (Multi Site Instance)
    6160function ms_create_default_template(){
    62     $active_templates = get_templates();
     61    $active_templates = $GLOBALS['templates'];
    6362
    6463    $api_key = get_site_option('api_key');
  • sendwithus/trunk/readme.txt

    r932728 r944671  
    5252== Changelog ==
    5353
     54=1.02=
     55* Now with less spamming of sendwithus’ servers!
     56
    5457= 1.01 =
    5558* Some bugfixes
  • sendwithus/trunk/sendwithus.php

    r934659 r944671  
    22/**
    33 * @package sendwithus
    4  * @version 1.01
     4 * @version 1.02
    55 */
    66/*
     
    1919require( 'inc/multisite_overrides.php' );
    2020
     21// API key is needed throughout.
     22$GLOBALS['api_key'] = get_api_key();
     23
    2124// Add stylesheet
    2225add_action( 'admin_enqueue_scripts', 'register_style_sheet' );
     
    2629}
    2730
    28 set_globals();
    29 
    30 if(is_network_admin()){
    31     $GLOBALS['api_key'] = get_site_option('api_key');
    32 }
    33 
    34 if ( $GLOBALS['api_key'] == '' || $GLOBALS['templates']->status == 'error' ) {
    35     $GLOBALS['valid_key'] = false;
    36 } else {
    37     // Establish whether an API key has been entered and that it is valid.
    38     $GLOBALS['valid_key'] = true;
    39     if(is_network_admin()){
    40         add_action( 'init', 'ms_create_default_template');
    41         // Some sites don't work with muplugins_loaded for some reason.
    42         // This will make default be created.
    43         if ( did_action('create_default_template') == 0 ) {
    44            add_action( 'plugins_loaded', 'ms_create_default_template');
    45         }
    46     }
    47     else{
    48         add_action( 'init', 'create_default_template');     
    49         // Some sites don't work with muplugins_loaded for some reason.
    50         // This will make default be created.
    51         if ( did_action('create_default_template') == 0 ) {
    52            add_action( 'plugins_loaded', 'create_default_template');
    53         }
    54     }
    55     add_action( 'plugins_loaded', 'set_globals');
    56 }
    57 
    5831// Used for displaying the main menu page.
    5932// Activated when user clicks on link in sidebar.
    6033function sendwithus_conf_main() {
     34    set_globals();
     35
     36    if(is_network_admin()){
     37        $GLOBALS['api_key'] = get_site_option('api_key');
     38    }
     39
     40    if ( $GLOBALS['api_key'] == '' || $GLOBALS['templates']->status == 'error' ) {
     41        $GLOBALS['valid_key'] = false;
     42    } else {
     43        // Establish whether an API key has been entered and that it is valid.
     44        $GLOBALS['valid_key'] = true;
     45        if(is_network_admin()){
     46            add_action( 'init', 'ms_create_default_template');
     47            // Some sites don't work with muplugins_loaded for some reason.
     48            // This will make default be created.
     49            if ( did_action('create_default_template') == 0 ) {
     50               add_action( 'plugins_loaded', 'ms_create_default_template');
     51            }
     52        }
     53        else{
     54            add_action( 'init', 'create_default_template');     
     55            // Some sites don't work with muplugins_loaded for some reason.
     56            // This will make default be created.
     57            if ( did_action('create_default_template') == 0 ) {
     58               add_action( 'plugins_loaded', 'create_default_template');
     59            }
     60        }
     61        add_action( 'plugins_loaded', 'set_globals');
     62    }
     63
    6164    // Make sure that the user has appropriate permissions to be here.
    6265    if ( ! current_user_can( 'manage_options' ) ) {
Note: See TracChangeset for help on using the changeset viewer.