public static function register() { // Register the method Controller::registerMethod('instapaper', array('Instapaper', 'page')); // Register the Instapaper service $service = new InstapaperService(); Services::register('instapaper', $service); // Register our options add_action('register_options', array('Instapaper', 'options')); add_action('options-form', array('Instapaper', 'admin')); }
$error_message = ' - ' . $error_message; } $subject = sprintf(__('Backup of %s Failed', 'backupwordpress'), $domain); $message = sprintf(__('BackUpWordPress was unable to backup your site %1$s.', 'backupwordpress') . "\n\n" . __('Here are the errors that we\'re encountered:', 'backupwordpress') . "\n\n" . '%2$s' . "\n\n" . __('If the errors above look like Martian, forward this email to %3$s and we\'ll take a look', 'backupwordpress') . "\n\n" . __("Kind Regards,\nThe Apologetic BackUpWordPress Backup Emailing Robot", 'backupwordpress'), home_url(), $error_message, '*****@*****.**'); wp_mail($this->get_email_address_array(), $subject, $message, $headers); return; } $subject = sprintf(__('Backup of %s', 'backupwordpress'), $domain); // If it's larger than the max attachment size limit assume it's not going to be able to send the backup if (@filesize($file) < hmbkp_get_max_attachment_size()) { $message = sprintf(__('BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress') . "\n\n" . __('The backup file should be attached to this email.', 'backupwordpress') . "\n\n" . __('You can download the backup file by clicking the link below:', 'backupwordpress') . "\n\n" . '%2$s' . "\n\n" . __("Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress'), home_url(), $download); $sent = wp_mail($this->get_email_address_array(), $subject, $message, $headers, $file); } // If we didn't send the email above then send just the notification if (!$sent) { $message = sprintf(__('BackUpWordPress has completed a backup of your site %1$s.', 'backupwordpress') . "\n\n" . __('Unfortunately the backup file was too large to attach to this email.', 'backupwordpress') . "\n\n" . __('You can download the backup file by clicking the link below:', 'backupwordpress') . "\n\n" . '%2$s' . "\n\n" . __("Kind Regards,\nThe Happy BackUpWordPress Backup Emailing Robot", 'backupwordpress'), home_url(), $download); wp_mail($this->get_email_address_array(), $subject, $message, $headers); } } } public static function intercom_data() { return array(); } public static function intercom_data_html() { } } // Register the service Services::register(__FILE__, 'HM\\BackUpWordPress\\Email_Service');
* Not in use * $return null */ public function update(&$new_data, $old_data) { } /** * Used to determine if the service is in use or not */ public function is_service_active() { return strlen($this->get_url()) > 0; } /** * @return string */ protected function get_url() { return defined('WPRP_PLUGIN_SLUG') && get_option('wpr_api_key') ? $this->wpremote_webhook_url : false; } /** * @return string */ protected function get_secret_key() { return get_option('wpr_api_key'); } } // Register the service Services::register(__FILE__, 'HM\\BackUpWordPress\\WPRemote_Webhook_Service');
function test_class_methods_get() { $services = new Services(); $services->register("DBHandler", "DBHandler"); //print_r($services->_registeredServices); $this->assertTrue($services->start("DBHandler")); $this->assertTrue($services->running("DBHandler")); $this->assertTrue(is_object($services->get("DBHandler"))); $this->assertEqual(get_class($services->get("DBHandler")), "dbhandler"); $this->assertReference($services->get("DBHandler"), $services->_services['DBHandler']); }