class SimpleWpMembership {
public function __construct() {
- add_action('admin_menu', array(&$this, 'menu'));
+ add_action('admin_menu', array(&$this, 'menu'));
add_action('init', array(&$this, 'init'));
add_filter('the_content', array(&$this, 'filter_content'),11,1);
add_action('profile_update', array(&$this, 'sync_with_wp_profile'), 10, 2);
add_action('wp_logout', array(&$this, 'wp_logout'));
add_action('wp_authenticate', array(&$this, 'wp_login'), 1, 2);
- add_action('swpm_logout', array(&$this, 'swpm_logout'));
-
+ add_action('swpm_logout', array(&$this, 'swpm_logout'));
+
//AJAX hooks
add_action('wp_ajax_swpm_validate_email', 'BAjax::validate_email_ajax');
add_action('wp_ajax_nopriv_swpm_validate_email', 'BAjax::validate_email_ajax');
add_action('plugins_loaded', array(&$this, "plugins_loaded"));
add_action('password_reset', array(&$this, 'wp_password_reset_hook'), 10, 2);
}
- function wp_password_reset_hook( $user, $pass )
+ function wp_password_reset_hook( $user, $pass )
{
$swpm_id = BUtils::get_user_by_user_name($user->user_login);
if (!empty($swpm_id)){
$password_hash = BUtils::encrypt_password($pass);
global $wpdb;
$wpdb->update($wpdb->prefix . "swpm_members_tbl", array('password' => $password_hash), array('member_id' => $swpm_id));
- }
+ }
}
-
+
public function save_attachment_extra($post, $attachment) {
$this->save_postdata($post['ID']);
return $post;
if(is_admin()){//No need to filter on the admin side
return $content;
}
-
+
$acl = BAccessControl::get_instance();
if (has_post_thumbnail($post_id)){ return $content;}
if ($acl->can_i_read_post($post_id)) {return $content;}
-
-
+
+
if (isset($content['file'])){
$content['file'] = 'restricted-icon.png';
$content['width'] = '400';
$content['height'] = '400';
}
-
+
if (isset($content['sizes'])){
if ($content['sizes']['thumbnail']){
$content['sizes']['thumbnail']['file'] = 'restricted-icon.png';
}
return $content;
}
-
+
public function filter_attachment_url($content, $post_id){
if(is_admin()){//No need to filter on the admin side
return $content;
}
$acl = BAccessControl::get_instance();
if (has_post_thumbnail($post_id)){return $content;}
-
+
if ($acl->can_i_read_post($post_id)){return $content;}
-
+
return BUtils::get_restricted_image_url();
}
-
+
public function admin_init_hook(){
BSettings::get_instance()->init_config_hooks();
$addon_saved = filter_input(INPUT_POST, 'swpm-addon-settings');
do_action('swpm_addon_settings_save');
}
}
-
+
public function hide_adminbar(){
if (!is_user_logged_in()){//Never show admin bar if the user is not even logged in
return false;
}
public function wp_login($username, $password) {
- $auth = BAuth::get_instance();
+ $auth = BAuth::get_instance();
if (($auth->is_logged_in() &&($auth->userData->user_name == $username))) {
return;
}
$query = "SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id !=1 ";
$levels = $wpdb->get_results($query, ARRAY_A);
foreach ($levels as $level) {
- echo '<input type="checkbox" checked="checked"' . (BPermission::get_instance($level['id'])->is_permitted($id) ? "checked='checked'" : "") .
+ echo '<input type="checkbox" ' . (BPermission::get_instance($level['id'])->is_permitted($id) ? "checked='checked'" : "") .
' name="swpm_protection_level[' . $level['id'] . ']" value="' . $level['id'] . '" /> ' . $level['alias'] . "<br/>";
}
}
}
private function edit_profile() {
- $swpm_editprofile_submit = filter_input(INPUT_POST, 'swpm_editprofile_submit');
+ $swpm_editprofile_submit = filter_input(INPUT_POST, 'swpm_editprofile_submit');
if (!empty($swpm_editprofile_submit)) {
BFrontRegistration::get_instance()->edit();
//todo: do a redirect
wp_enqueue_script('password-strength-meter');
wp_enqueue_script('swpm.password-meter', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.password-meter.js');
wp_enqueue_style('jquery.tools.dateinput', SIMPLE_WP_MEMBERSHIP_URL . '/css/jquery.tools.dateinput.css');
- wp_enqueue_script('jquery.tools', SIMPLE_WP_MEMBERSHIP_URL . '/js/jquery.tools18.min.js');
+ wp_enqueue_script('jquery.tools', SIMPLE_WP_MEMBERSHIP_URL . '/js/jquery.tools18.min.js');
$settings = array('statusChangeEmailHead'=> BSettings::get_instance()->get_value('account-change-email-subject'),
'statusChangeEmailBody'=> BSettings::get_instance()->get_value('account-change-email-body'));
- wp_localize_script( 'swpm.password-meter', 'SwpmSettings', $settings );
+ wp_localize_script( 'swpm.password-meter', 'SwpmSettings', $settings );
}
public function front_library() {
return;
}
$is_free = BSettings::get_instance()->get_value('enable-free-membership');
- $free_level = absint(BSettings::get_instance()->get_value('free-membership-id'));
+ $free_level = absint(BSettings::get_instance()->get_value('free-membership-id'));
$level = isset($atts['level'])? absint($atts['level']): ($is_free? $free_level: null);
return BFrontRegistration::get_instance()->regigstration_ui($level);
}
'manage_options', 'simple_wp_membership_payments', array(&$this, "payments_menu"));
add_submenu_page($menu_parent_slug, __("Add-ons", 'swpm'), __("Add-ons", 'swpm'),
'manage_options', 'simple_wp_membership_addons', array(&$this, "add_ons_menu"));
-
+
do_action('swpm_after_main_admin_menu', $menu_parent_slug);
$this->meta_box();
switch ($current_tab) {
case 6:
include(SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_addon_settings.php');
- break;
+ break;
case 4:
$link_for = filter_input(INPUT_POST, 'swpm_link_for',FILTER_SANITIZE_STRING);
$member_id = filter_input(INPUT_POST, 'member_id',FILTER_SANITIZE_NUMBER_INT);
break;
}
}
-
+
public function payments_menu(){
include(SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_payments_page.php');
}
-
+
public function add_ons_menu(){
include(SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_add_ons_page.php');
}
include_once('class.bInstallation.php');
BInstallation::run_safe_installer();
}
- }
+ }
}
-
+
public static function activate() {
wp_schedule_event(time(), 'daily', 'swpm_account_status_event');
wp_schedule_event(time(), 'daily', 'swpm_delete_pending_account_event');
include_once('class.bInstallation.php');
BInstallation::run_safe_installer();
}
-
+
public function deactivate() {
wp_clear_scheduled_hook('swpm_account_status_event');
- wp_clear_scheduled_hook('swpm_delete_pending_account_event');
+ wp_clear_scheduled_hook('swpm_delete_pending_account_event');
}
private function verify_and_delete_account(){
include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'classes/class.bMembers.php');
if (empty($password)){
BUtils::account_delete_confirmation_ui();
}
-
+
$nonce_field = filter_input(INPUT_POST, 'account_delete_confirm_nonce');
if (empty($nonce_field) || !wp_verify_nonce($nonce_field, 'swpm_account_delete_confirm')){
BUtils::account_delete_confirmation_ui(BUtils::_("Sorry, Nonce verification failed."));
- }
+ }
if ($auth->match_password($password)){
$auth->delete();
wp_redirect(home_url());