Exemple #1
0
 /**
  * Instantiates and returns class singleton
  *
  * @since  0.1
  * @return RUA_App 
  */
 public static function instance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * Display duration column
  *
  * @since  0.5
  * @param  string  $column_name
  * @param  int     $post_id
  * @return string
  */
 protected function column_duration($column_name, $post_id)
 {
     $metadata = RUA_App::instance()->level_manager->metadata()->get($column_name);
     $retval = "";
     if ($metadata) {
         $data = $metadata->get_data($post_id);
         if (isset($data["count"], $data["unit"]) && $data["count"]) {
             $list = RUA_App::instance()->level_manager->metadata()->get($column_name)->get_input_list();
             $retval = $data["count"] . " " . $list[$data["unit"]];
         } else {
             $retval = __("Unlimited", RUA_App::DOMAIN);
         }
     }
     return $retval;
 }
 /**
  * Save metadata values for restriction
  *
  * @since  0.1
  * @param  int  $post_id 
  * @return void 
  */
 public function save_post($post_id)
 {
     // Save button pressed
     if (!isset($_POST['original_publish']) && !isset($_POST['save_post'])) {
         return;
     }
     // Only sidebar type
     if (get_post_type($post_id) != RUA_App::TYPE_RESTRICT) {
         return;
     }
     // Verify nonce
     if (!check_admin_referer(WPCACore::PREFIX . $post_id, WPCACore::NONCE)) {
         return;
     }
     // Check permissions
     if (!current_user_can(RUA_App::CAPABILITY, $post_id)) {
         return;
     }
     // Check autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Update metadata
     foreach (RUA_App::instance()->level_manager->metadata()->get_all() as $field) {
         $new = isset($_POST[$field->get_id()]) ? $_POST[$field->get_id()] : '';
         $old = $field->get_data($post_id);
         if ($new != '' && $new != $old) {
             $field->update($post_id, $new);
         } elseif ($new == '' && $old != '') {
             $field->delete($post_id, $old);
         }
     }
 }
 /**
  * Render expiry date column
  *
  * @since  0.5
  * @param  WP_User  $user
  * @return string
  */
 protected function column_status($user)
 {
     $expiry = RUA_App::instance()->level_manager->get_user_level_expiry($user, get_the_ID());
     $status = __("Active", RUA_App::DOMAIN);
     if ($expiry) {
         $is_expired = RUA_App::instance()->level_manager->is_user_level_expired($user, get_the_ID());
         $h_time = date_i18n(get_option('date_format'), $expiry);
         $t_time = date_i18n(__('Y/m/d') . " " . get_option("time_format"), $expiry);
         $status = $is_expired ? __("Expired %s", RUA_App::DOMAIN) : __("Active until %s", RUA_App::DOMAIN);
         $status = sprintf($status, '<abbr title="' . $t_time . '">' . $h_time . '</abbr>');
     }
     return $status;
 }
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('ABSPATH')) {
    header('Status: 403 Forbidden');
    header('HTTP/1.1 403 Forbidden');
    exit;
}
$rua_plugin_path = plugin_dir_path(__FILE__);
require $rua_plugin_path . '/lib/wp-content-aware-engine/core.php';
require $rua_plugin_path . '/app.php';
require $rua_plugin_path . '/level.php';
if (is_admin()) {
    require $rua_plugin_path . '/lib/wp-db-updater/wp-db-updater.php';
    require $rua_plugin_path . '/db_updates.php';
    require $rua_plugin_path . '/admin/level-edit.php';
    require $rua_plugin_path . '/admin/level-overview.php';
    require $rua_plugin_path . "/list-members.php";
}
// Launch plugin
RUA_App::instance();
//eol