function WPML_init($file) { require_once 'WPML_Plugin.php'; require_once 'WPML_LogRotation.php'; require_once plugin_dir_path(__FILE__) . 'inc/redux/admin-init.php'; $aPlugin = new WPML_Plugin(); // For Testing make plugin available global if (!array_key_exists('WPML_Plugin', $GLOBALS)) { $GLOBALS['WPML_Plugin'] =& $aPlugin; } // Install the plugin // NOTE: this file gets run each time you *activate* the plugin. // So in WP when you "install" the plugin, all that does it dump its files in the plugin-templates directory // but it does not call any of its code. // So here, the plugin tracks whether or not it has run its install operation, and we ensure it is run only once // on the first activation if (!$aPlugin->isInstalled()) { $aPlugin->install(); } else { // Perform any version-upgrade activities prior to activation (e.g. database changes) $aPlugin->upgrade(); } // Add callbacks to hooks $aPlugin->addActionsAndFilters(); if (!$file) { $file = __FILE__; } // Register the Plugin Activation Hook register_activation_hook($file, array(&$aPlugin, 'activate')); // Register the Plugin Deactivation Hook register_deactivation_hook($file, array(&$aPlugin, 'deactivate')); }
/** * Executes log rotation periodically. * @since 1.4 */ static function LogRotationSchedule() { global $wpml_settings, $wpdb; $tableName = WPML_Plugin::getTablename('mails'); if ($wpml_settings['log-rotation-limit-amout'] == '1') { $keep = $wpml_settings['log-rotation-limit-amout-keep']; if ($keep > 0) { $wpdb->query("DELETE p\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t{$tableName} AS p\n\t\t\t\t\t\tJOIN\n\t\t\t\t\t\t( SELECT mail_id\n\t\t\t\t\t\tFROM {$tableName}\n\t\t\t\t\t\tORDER BY mail_id DESC\n\t\t\t\t\t\tLIMIT 1 OFFSET {$keep}\n\t\t\t\t) AS lim\n\t\t\t\t\t\tON p.mail_id <= lim.mail_id;"); } } if ($wpml_settings['log-rotation-delete-time'] == '1') { $days = $wpml_settings['log-rotation-delete-time-days']; if ($days > 0) { $wpdb->query("DELETE FROM {$tableName} WHERE DATEDIFF(now(), timestamp) >= {$days}"); } } }
/** * Processes bulk actions. * @since 1.0 */ function process_bulk_action() { global $wpdb; if (false === $this->current_action()) { return; } if (check_admin_referer(Email_Logging_ListTable::NONCE_LIST_TABLE, Email_Logging_ListTable::NONCE_LIST_TABLE . '_nonce')) { $name = $this->_args['singular']; $tableName = WPML_Plugin::getTablename('mails'); //Detect when a bulk action is being triggered... if ('delete' == $this->current_action()) { foreach ($_REQUEST[$name] as $item_id) { $wpdb->query($wpdb->prepare("DELETE FROM `{$tableName}` WHERE `mail_id` = %d", esc_sql($item_id)), ARRAY_A); } } } }
public function log_email($mailOriginal) { // make copy to avoid any changes on the original mail $mail = $mailOriginal; global $wpdb; $fields = $this->extractFields($mail); $tableName = WPML_Plugin::getTablename('mails'); $wpdb->insert($tableName, $fields); return $mailOriginal; }
function process_bulk_action() { global $wpdb; $name = $this->_args['singular']; $tableName = WPML_Plugin::getTablename('mails'); //Detect when a bulk action is being triggered... if ('delete' == $this->current_action()) { foreach ($_REQUEST[$name] as $item_id) { $wpdb->query($wpdb->prepare("DELETE FROM `{$tableName}` WHERE `mail_id` = %d", $item_id)); } } }