function filter_AdminUrl($url, $path) { if (strpos($path, 'profile.php') !== false && !am4PluginsManager::skipProtection() && am4PluginsManager::getOption('profile_redirect')) { return am4PluginsManager::getAPI()->getProfileURL(); } return $url; }
" /> <title><?php _e('Rich Editor Help'); ?> </title> <script type="text/javascript" src="<?php print get_option('siteurl'); ?> /wp-includes/js/tinymce/tiny_mce_popup.js?ver=3223"></script> <?php wp_admin_css('global', true); wp_admin_css('wp-admin', true); do_action('admin_print_styles'); do_action('admin_print_scripts'); do_action('admin_head'); // Include amember styles and scripts; ?> </head> <body> <h2><?php _e('aMember Shortcodes', 'am4-plugin'); ?> </h2> <?php $plugin = am4PluginsManager::getPlugin('shortcodes'); print $plugin->getHelp(); ?> </body> </html>
function resourceAccess($id, $access = array(), $varname = 'access', $text = null, $without_period = false) { if (!$text) { $text = __('Choose Products and/or Product Categories that allows access', 'am4-plugin'); } $uniqid = uniqid('amw-'); ?> <div class="resourceaccess <?php echo $uniqid; ?> " id="<?php echo $id; ?> " data-varname='<?php echo $varname; ?> '><?php _e($text); ?> <br/> <input type='hidden' class='resourceaccess-init' value='<?php if ($access) { $this->e(aMemberJson::init($this->addProductTitle($access))); } else { print '{}'; } ?> ' /> <select class='category' size=1> <option value='' ><?php _e('Please select an item...', 'am4-plugin'); ?> </option> <optgroup class='category' label='<?php _e('Product Categories', 'am4-plugin'); ?> '> <option value='-1' style='font-weight: bold'><?php _e('Any Product', 'am4-plugin'); ?> </option> <?php $this->options(am4PluginsManager::getAMCategories()); ?> </optgroup> <optgroup class='product' label='<?php _e('Products', 'am4-plugin'); ?> '> <?php $this->options(am4PluginsManager::getAMProducts()); ?> </optgroup> </select> <div class='category-list'></div> <div class='product-list'></div> <br /> </div> <script type="text/javascript"> jQuery(document).ready(function ($){ jQuery('.<?php echo $uniqid; ?> ').resourceAccess({without_period: <?php echo $without_period ? 'true' : 'false'; ?> }); }); </script> <?php }
function run($atts = array(), $content = '') { $errors = am4Errors::getInstance(); if (!am4PluginsManager::getAPI()->isLoggedIn()) { return do_shortcode($errors->get($atts['guest_error'])); } if (!am4PluginsManager::getAPI()->isUserActive()) { return do_shortcode($errors->get($atts['user_error'])); } $access = new am4UserAccess(); //User is logged in let's check his access level; if ($atts['have']) { $records = $this->convertToAccessRequirement($atts['have']); if (!$access->anyTrue($records)) { return do_shortcode($errors->get($atts['user_error'])); } } if ($atts['not_have']) { $records = $this->convertToAccessRequirement($atts['not_have']); if (!$access->allFalse($records)) { return do_shortcode($errors->get($atts['user_error'])); } } return do_shortcode($content); }
function filter_WpNavMenuObjects($items, $args) { if (am4PluginsManager::skipProtection()) { return $items; } $access = new am4UserAccess(); $type = $access->isLoggedIn() ? "user" : "guest"; foreach ($items as $id => $i) { switch ($i->object) { case 'page': case 'post': // get_page and get_post are identical; $page = get_page($i->object_id); $settings = $this->getPostAccess($page); if ($settings->{'only_guest'}) { if ($type != 'guest') { unset($items['id']); } } else { if ($settings->{'protected'} && !$this->haveAccess($this->getPostRequirements($page), $settings) && $settings->{$type . '_action_menu'} == 'hide') { unset($items[$id]); } } break; case 'category': $settings = new am4_Settings_Category($i->object_id); if ($settings->{'protected'} && !$this->haveAccess(am4AccessRequirement::createRequirements($settings->{'access'}), $settings) && $settings->{$type . '_action_cat_menu'} == 'hide') { unset($items[$id]); } break; } } return $items; }
function widget($args, $instance) { global $current_user; if (am4PluginsManager::get("widgets")->isWidgetAvailable($this, $instance)) { return parent::widget($args, $instance); } }
static function staticAction() { if (am4Request::$method != 'POST') { return; } if (!current_user_can('manage_options')) { return ''; } if (!check_admin_referer('am4MenuPageFormController')) { throw new Exception('Security check!'); } $options = get_magic_quotes_gpc() ? stripslashes_deep(am4Request::get('options')) : am4Request::get('options'); try { am4PluginsManager::initAPI(@$options['path']); } catch (Exception $e) { } }
/** * * @return Am_Lite */ static function getAPI() { if (!self::$api) { try { self::initAPI(); self::$api = Am_Lite::getInstance(); } catch (Exception $e) { return false; } } return self::$api; }
function getAccessCache() { return am4PluginsManager::getAPI()->getAccessCache(); }
function run($atts = array(), $content = '') { $ret = ''; if (($api = am4PluginsManager::getAPI()) && $api->isLoggedIn()) { $user = $api->getUser(); $url = am4PluginsManager::getAmemberURL(); $vars = array('r' => $user['user_id']); if (array_key_exists('id', $atts) && $atts['id']) { $vars['i'] = $atts['id']; } if (array_key_exists('title', $atts) && $atts['title']) { $ret = sprintf("<a href='%s/aff/go?%s'>%s</a>", $url, http_build_query($vars, '', '&'), $title); } else { $ret = sprintf("%s/aff/go?%s", $url, http_build_query($vars, '', '&')); } } return $ret; }
function filter_TheContent($content) { $api = am4PluginsManager::getAPI(); if (current_user_can("manage_options")) { return $content; } $access = new am4UserAccess(); $type = $api->isLoggedIn() ? "user" : "guest"; if (is_single()) { $post = $GLOBALS['post']; if (!$post) { return $content; } $settings = $this->getPostAccess($post); if ($settings['protected'] && (!$access->isLoggedIn() || !$access->anyTrue($this->getPostRequirements($post)))) { switch ($settings[$type . '_action']) { case 'text': $content = $this->getErrorText($settings[$type . '_action_text']); break; } } } return $content; }
function validate($options) { try { am4PluginsManager::initAPI($options['path']); } catch (Exception $ex) { return $ex->getMessage(); } return true; }