Plugin Directory

Changeset 1749023


Ignore:
Timestamp:
10/19/2017 06:56:34 AM (7 years ago)
Author:
ekamiya
Message:

ver.1.0.3; code changes for performance.

Location:
simple-schedule-notice/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-schedule-notice/trunk/readme.txt

    r1718499 r1749023  
    44Tags: reminder,notice,notification,schedule,mail
    55Requires at least:
    6 Tested up to: 4.8.1
     6Tested up to: 4.8.2
    77Stable tag: trunk
    88License: GPLv2 or later
  • simple-schedule-notice/trunk/simple-schedule-notice.php

    r1708107 r1749023  
    1717  var $module_title, $menu_title;
    1818  var $sys_timezone, $wp_timezone, $msg, $system_error;
     19  var $actionhooks;
    1920
    2021  //constructor
     
    2627    register_deactivation_hook( __FILE__, array($this, 'simschntc_deactivation' ) );
    2728    //setup events
    28     foreach ( $this->actionhooks() as $hook => $action ) {
    29       add_action( $hook, array($this, $action ) );
     29    $this->actionhooks = array(
     30      cActionHook           => 'simschntc_process_event',
     31      cActionHook_immediate => 'simschntc_process_event',
     32      cActionHook_test      => 'simschntc_process_testevent'
     33    );
     34    foreach ( $this->actionhooks as $hook => $action ) {
     35      add_action( $hook, array( $this, $action ));
    3036    }
    3137    //omit appending posttype on mail title
     
    266272              <?php
    267273              $shedcnt = 0;
    268               foreach ( array_keys( $this->actionhooks() ) as $hook ) {
     274              foreach ( array_keys( $this->actionhooks ) as $hook ) {
    269275                $shcdinfo = wp_next_scheduled( $hook );
    270276                if ( $shcdinfo ) {
     
    480486    $maillist     = array();
    481487    if ( !$post_meta_info[ 'suppress_default1' ] ) {
    482       $this->array_add( $maillist, $base_info[ 'default_mailaddr1' ] );
     488      $this->array_append( $maillist, $base_info[ 'default_mailaddr1' ] );
    483489    }
    484490    if ( !$post_meta_info[ 'suppress_default2' ] ) {
    485       $this->array_add( $maillist, $base_info[ 'default_mailaddr2' ] );
    486     }
    487     $this->array_add( $maillist, $post_meta_info[ 'mailaddr1' ] );
    488     $this->array_add( $maillist, $post_meta_info[ 'mailaddr2' ] );
     491      $this->array_append( $maillist, $base_info[ 'default_mailaddr2' ] );
     492    }
     493    $this->array_append( $maillist, $post_meta_info[ 'mailaddr1' ] );
     494    $this->array_append( $maillist, $post_meta_info[ 'mailaddr2' ] );
    489495    // vv... seems Array doesnt work. ...vv
    490496    //$result = wp_mail($maillist, ($testmode ? __( 'テスト送信:', cPluginID ) : '').$post_title, $post_content);
     
    653659//  or $default value if array value is not defined.
    654660// if the type of $default is boolean, either 'true', 'on' or 'yes' returns TRUE.
     661    $ret = $default;
    655662    if ( isset( $array[ $key ] ) ) {
    656663      $ret = $array[ $key ];
     
    695702          break;
    696703      }
    697     } else {
    698       $ret = $default;
    699704    }
    700705    return $ret;
     
    705710  }
    706711
    707   private function array_add( &$arr, $newmember ) {
    708     // Add new member to the array, if $newmember is not empty.
     712  private function array_append( &$arr, $memb ) {
     713    // Add new member to the array, if $memb is not empty.
    709714    // Returns nothing.
    710     if ( !empty( $newmember ) ) {
    711       $arr[] = $newmember;
     715    if ( ! empty( $memb ) ) {
     716      if ( is_array( $memb )) {
     717        foreach ( $memb as $elem ) {
     718          $arr[] = $elem;
     719        }
     720      } else {
     721        $arr[] = $memb;
     722      }
    712723    }
    713724  }
     
    823834      wp_clear_scheduled_hook( $hook );
    824835    } else {
    825       foreach ( array_keys( $this->actionhooks() ) as $hook ) {
     836      foreach ( array_keys( $this->actionhooks ) as $hook ) {
    826837        $shcdinfo = wp_next_scheduled( $hook );
    827838        if ( $shcdinfo ) {
     
    858869  }
    859870
    860   private function actionhooks() {
    861     //Returns event hook list
    862     return array(
    863       cActionHook           => 'simschntc_process_event',
    864       cActionHook_immediate => 'simschntc_process_event',
    865       cActionHook_test      => 'simschntc_process_testevent'
    866     );
    867   }
    868 
    869871  private function cycledef() {
    870872    return array(
Note: See TracChangeset for help on using the changeset viewer.