本文整理汇总了PHP中SwpmUtils::_方法的典型用法代码示例。如果您正苦于以下问题:PHP SwpmUtils::_方法的具体用法?PHP SwpmUtils::_怎么用?PHP SwpmUtils::_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SwpmUtils
的用法示例。
在下文中一共展示了SwpmUtils::_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_level
public function edit_level($id)
{
//Check we are on the admin end and user has management permission
SwpmMiscUtils::check_user_permission_and_is_admin('membership level edit');
//Check nonce
if (!isset($_POST['_wpnonce_edit_swpmlevel_admin_end']) || !wp_verify_nonce($_POST['_wpnonce_edit_swpmlevel_admin_end'], 'edit_swpmlevel_admin_end')) {
//Nonce check failed.
wp_die(SwpmUtils::_("Error! Nonce verification failed for membership level edit from admin end."));
}
global $wpdb;
$query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $id);
$level = $wpdb->get_row($query, ARRAY_A);
$form = new SwpmLevelForm($level);
if ($form->is_valid()) {
$wpdb->update($wpdb->prefix . "swpm_membership_tbl", $form->get_sanitized(), array('id' => $id));
//@todo meta table and collect all relevant info and pass as argument
$custom = apply_filters('swpm_admin_edit_membership_level', array(), $id);
$this->save_custom_fields($id, $custom);
$message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Membership Level Updated Successfully.') . '</p>');
SwpmTransfer::get_instance()->set('status', $message);
wp_redirect('admin.php?page=simple_wp_membership_levels');
exit(0);
}
$message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors());
SwpmTransfer::get_instance()->set('status', $message);
}
示例2: swpm_ty_page_rego_sc
public function swpm_ty_page_rego_sc($args)
{
$output = '';
$settings = SwpmSettings::get_instance();
//If user is logged in then the purchase will be applied to the existing profile
if (SwpmMemberUtils::is_member_logged_in()) {
$username = SwpmMemberUtils::get_logged_in_members_username();
$output .= '<div class="swpm-ty-page-registration-logged-in swpm-yellow-box">';
$output .= '<p>' . SwpmUtils::_('Your membership profile will be updated to reflect the payment.') . '</p>';
$output .= SwpmUtils::_('Your profile username: ') . $username;
$output .= '</div>';
return $output;
}
$output .= '<div class="swpm-ty-page-registration">';
$member_data = SwpmUtils::get_incomplete_paid_member_info_by_ip();
if ($member_data) {
//Found a member profile record for this IP that needs to be completed
$reg_page_url = $settings->get_value('registration-page-url');
$rego_complete_url = add_query_arg(array('member_id' => $member_data->member_id, 'code' => $member_data->reg_code), $reg_page_url);
$output .= '<div class="swpm-ty-page-registration-link swpm-yellow-box">';
$output .= '<p>' . SwpmUtils::_('Click on the following link to complete the registration.') . '</p>';
$output .= '<p><a href="' . $rego_complete_url . '">' . SwpmUtils::_('Click here to complete your paid registration') . '</a></p>';
$output .= '</div>';
} else {
//Nothing found. Check again later.
$output .= '<div class="swpm-ty-page-registration-link swpm-yellow-box">';
$output .= SwpmUtils::_('If you have just made a membership payment then your payment is yet to be processed. Please check back in a few minutes. An email will be sent to you with the details shortly.');
$output .= '</div>';
}
$output .= '</div>';
//end of .swpm-ty-page-registration
return $output;
}
示例3: column_user_name
function column_user_name($item)
{
$user_name = $item['user_name'];
if (empty($user_name)) {
$user_name = '[' . SwpmUtils::_('incomplete') . ']';
}
return $user_name;
}
示例4: get_logged_in_members_level_name
public static function get_logged_in_members_level_name()
{
$auth = SwpmAuth::get_instance();
if ($auth->is_logged_in()) {
return $auth->get('alias');
}
return SwpmUtils::_("User is not logged in.");
}
示例5: validate_user_name_ajax
public static function validate_user_name_ajax()
{
global $wpdb;
$field_value = filter_input(INPUT_GET, 'fieldValue');
$field_id = filter_input(INPUT_GET, 'fieldId');
$table = $wpdb->prefix . "swpm_members_tbl";
$query = $wpdb->prepare("SELECT COUNT(*) FROM {$table} WHERE user_name = %s", $field_value);
$exists = $wpdb->get_var($query) > 0;
echo '[ "' . $field_id . ($exists ? '",false,"χ ' . SwpmUtils::_('Aready taken') . '"]' : '",true,"√ ' . SwpmUtils::_('Available') . '"]');
exit;
}
示例6: process_delete_action
function process_delete_action()
{
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_payment_btn') {
//Delete link was clicked for a row in list table
$record_id = strip_tags($_REQUEST['button_id']);
wp_delete_post($record_id);
$success_msg = '<div id="message" class="updated"><p>';
$success_msg .= SwpmUtils::_('The selected entry was deleted!');
$success_msg .= '</p></div>';
echo $success_msg;
}
}
示例7: swpm_show_expiry_date_sc
public function swpm_show_expiry_date_sc($args)
{
$output = '<div class="swpm-show-expiry-date">';
if (SwpmMemberUtils::is_member_logged_in()) {
$auth = SwpmAuth::get_instance();
$expiry_date = $auth->get_expire_date();
$output .= SwpmUtils::_('Expiry: ') . $expiry_date;
} else {
$output .= SwpmUtils::_('You are not logged-in as a member');
}
$output .= '</div>';
return $output;
}
示例8: update_category_list
public static function update_category_list()
{
$selected = filter_input(INPUT_POST, 'membership_level_id');
$selected_level_id = empty($selected) ? 1 : $selected;
$category = $selected_level_id == 1 ? SwpmProtection::get_instance() : SwpmPermission::get_instance($selected_level_id);
$args = array('ids' => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY));
$filtered = filter_input_array(INPUT_POST, $args);
$ids = $filtered['ids'];
$args = array('ids_in_page' => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY));
$filtered = filter_input_array(INPUT_POST, $args);
$ids_in_page = $filtered['ids_in_page'];
$category->remove($ids_in_page, 'category')->apply($ids, 'category')->save();
$message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Category protection updated!') . '</p>');
SwpmTransfer::get_instance()->set('status', $message);
}
示例9: edit
public function edit($id)
{
global $wpdb;
$query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $id);
$level = $wpdb->get_row($query, ARRAY_A);
$form = new SwpmLevelForm($level);
if ($form->is_valid()) {
$wpdb->update($wpdb->prefix . "swpm_membership_tbl", $form->get_sanitized(), array('id' => $id));
//@todo meta table and collect all relevant info and pass as argument
$custom = apply_filters('swpm_admin_edit_membership_level', array(), $id);
$this->save_custom_fields($id, $custom);
$message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Updated Successfully.') . '</p>');
SwpmTransfer::get_instance()->set('status', $message);
wp_redirect('admin.php?page=simple_wp_membership_levels');
exit(0);
}
$message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors());
SwpmTransfer::get_instance()->set('status', $message);
}
示例10: check_and_restrict_comment_posting_to_members
public static function check_and_restrict_comment_posting_to_members()
{
$allow_comments = SwpmSettings::get_instance()->get_value('members-login-to-comment');
if (empty($allow_comments)) {
return;
}
if (is_admin()) {
return;
}
if (SwpmAuth::get_instance()->is_logged_in()) {
return;
}
$comment_id = filter_input(INPUT_POST, 'comment_post_ID');
if (empty($comment_id)) {
return;
}
//Stop this request -> 1)we are on the front-side. 2) Comment posted by a not logged in member. 3) comment_post_ID missing.
$_POST = array();
wp_die(SwpmUtils::_('Comments not allowed by a non-member.'));
}
示例11: swpm_load_template
public static function swpm_load_template($template_name, $require_once = true)
{
//List of file paths (in order of priority) where the plugin should check for the template.
$template_files = array(get_stylesheet_directory() . '/' . SIMPLE_WP_MEMBERSHIP_TEMPLATE_PATH . '/' . $template_name, get_template_directory() . '/' . SIMPLE_WP_MEMBERSHIP_TEMPLATE_PATH . '/' . $template_name, SIMPLE_WP_MEMBERSHIP_PATH . 'views/' . $template_name);
//Filter hook to allow overriding of the template file path
$template_files = apply_filters('swpm_load_template_files', $template_files, $template_name);
foreach ($template_files as $file) {
if (file_exists($file)) {
$template_to_load = $file;
break;
}
}
//Lets load this template
if ($template_to_load) {
if ($require_once) {
require_once $template_to_load;
} else {
require $template_to_load;
}
} else {
wp_die(SwpmUtils::_('Error! Failed to find a template path for the specified template: ' . $template_name));
}
}
示例12: subscription_period
protected function subscription_period()
{
$subscript_duration_type = filter_input(INPUT_POST, 'subscription_duration_type');
if ($subscript_duration_type == SwpmMembershipLevel::NO_EXPIRY) {
$this->sanitized['subscription_period'] = "";
return;
}
$subscription_period = filter_input(INPUT_POST, 'subscription_period_' . $subscript_duration_type);
if ($subscript_duration_type == SwpmMembershipLevel::FIXED_DATE) {
$dateinfo = date_parse($subscription_period);
if ($dateinfo['warning_count'] || $dateinfo['error_count']) {
$this->errors['subscription_period'] = SwpmUtils::_("Date format is not valid.");
return;
}
$this->sanitized['subscription_period'] = sanitize_text_field($subscription_period);
return;
}
if (!is_numeric($subscription_period)) {
$this->errors['subscription_period'] = SwpmUtils::_("Access duration must be > 0.");
return;
}
$this->sanitized['subscription_period'] = sanitize_text_field($subscription_period);
}
示例13: delete_account_button
public static function delete_account_button()
{
$allow_account_deletion = SwpmSettings::get_instance()->get_value('allow-account-deletion');
if (empty($allow_account_deletion)) {
return "";
}
return '<a href="/?delete_account=1"><div class="swpm-account-delete-button">' . SwpmUtils::_("Delete Account") . '</div></a>';
}
示例14: handle_main_membership_level_admin_menu
function handle_main_membership_level_admin_menu()
{
do_action('swpm_membership_level_menu_start');
$level_action = filter_input(INPUT_GET, 'level_action');
$action = $level_action;
$selected = $action;
?>
<div class="wrap swpm-admin-menu-wrap"><!-- start wrap -->
<!-- page title -->
<h1><?php
echo SwpmUtils::_('Simple WP Membership::Membership Levels');
?>
</h1>
<!-- start nav menu tabs -->
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php
echo $selected == "" ? 'nav-tab-active' : '';
?>
" href="admin.php?page=simple_wp_membership_levels"><?php
echo SwpmUtils::_('Membership Levels');
?>
</a>
<a class="nav-tab <?php
echo $selected == "add" ? 'nav-tab-active' : '';
?>
" href="admin.php?page=simple_wp_membership_levels&level_action=add"><?php
echo SwpmUtils::_('Add Level');
?>
</a>
<a class="nav-tab <?php
echo $selected == "manage" ? 'nav-tab-active' : '';
?>
" href="admin.php?page=simple_wp_membership_levels&level_action=manage"><?php
echo SwpmUtils::_('Manage Content Production');
?>
</a>
<a class="nav-tab <?php
echo $selected == "category_list" ? 'nav-tab-active' : '';
?>
" href="admin.php?page=simple_wp_membership_levels&level_action=category_list"><?php
echo SwpmUtils::_('Category Protection');
?>
</a>
<?php
//Trigger hooks that allows an extension to add extra nav tabs in the membership levels menu.
do_action('swpm_membership_levels_menu_nav_tabs', $selected);
$menu_tabs = apply_filters('swpm_membership_levels_additional_menu_tabs_array', array());
foreach ($menu_tabs as $level_action => $title) {
?>
<a class="nav-tab <?php
echo $selected == $member_action ? 'nav-tab-active' : '';
?>
" href="admin.php?page=simple_wp_membership_levels&level_action=<?php
echo $level_action;
?>
" ><?php
SwpmUtils::e($title);
?>
</a>
<?php
}
?>
</h2>
<!-- end nav menu tabs -->
<?php
do_action('swpm_membership_level_menu_after_nav_tabs');
//Trigger hook so anyone listening for this particular action can handle the output.
do_action('swpm_membership_level_menu_body_' . $action);
//Allows an addon to completely override the body section of the membership level admin menu for a given action.
$output = apply_filters('swpm_membership_level_menu_body_override', '', $action);
if (!empty($output)) {
//An addon has overriden the body of this page for the given action. So no need to do anything in core.
echo $output;
echo '</div>';
//<!-- end of wrap -->
return;
}
//Switch case for the various different actions handled by the core plugin.
switch ($action) {
case 'add':
case 'edit':
$this->process_form_request();
break;
case 'manage':
$this->manage();
break;
case 'category_list':
$this->manage_categroy();
break;
case 'delete':
$this->delete_level();
default:
$this->show_levels();
break;
}
echo '</div>';
//.........这里部分代码省略.........
示例15: swpm_render_pp_subscription_button_sc_output
function swpm_render_pp_subscription_button_sc_output($button_code, $args)
{
$button_id = isset($args['id']) ? $args['id'] : '';
if (empty($button_id)) {
return '<p style="color: red;">Error! swpm_render_pp_subscription_button_sc_output() function requires the button ID value to be passed to it.</p>';
}
//Check new_window parameter
$window_target = isset($args['new_window']) ? 'target="_blank"' : '';
$settings = SwpmSettings::get_instance();
$button_cpt = get_post($button_id);
//Retrieve the CPT for this button
$membership_level_id = get_post_meta($button_id, 'membership_level_id', true);
$paypal_email = get_post_meta($button_id, 'paypal_email', true);
$payment_currency = get_post_meta($button_id, 'payment_currency', true);
//Subscription payment details
$billing_amount = get_post_meta($button_id, 'billing_amount', true);
if (!is_numeric($billing_amount)) {
return '<p style="color: red;">Error! The billing amount value of the button must be a numeric number. Example: 49.50 </p>';
}
$billing_amount = round($billing_amount, 2);
//round the amount to 2 decimal place.
$billing_cycle = get_post_meta($button_id, 'billing_cycle', true);
$billing_cycle_term = get_post_meta($button_id, 'billing_cycle_term', true);
$billing_cycle_count = get_post_meta($button_id, 'billing_cycle_count', true);
$billing_reattempt = get_post_meta($button_id, 'billing_reattempt', true);
//Trial billing details
$trial_billing_amount = get_post_meta($button_id, 'trial_billing_amount', true);
if (!empty($trial_billing_amount)) {
if (!is_numeric($trial_billing_amount)) {
return '<p style="color: red;">Error! The trial billing amount value of the button must be a numeric number. Example: 19.50 </p>';
}
}
$trial_billing_cycle = get_post_meta($button_id, 'trial_billing_cycle', true);
$trial_billing_cycle_term = get_post_meta($button_id, 'trial_billing_cycle_term', true);
$sandbox_enabled = $settings->get_value('enable-sandbox-testing');
$notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_ipn=1';
$return_url = get_post_meta($button_id, 'return_url', true);
if (empty($return_url)) {
$return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
}
$cancel_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
$user_ip = SwpmUtils::get_user_ip_address();
$_SESSION['swpm_payment_button_interaction'] = $user_ip;
//Custom field data
$custom_field_value = 'subsc_ref=' . $membership_level_id;
$custom_field_value .= '&user_ip=' . $user_ip;
if (SwpmMemberUtils::is_member_logged_in()) {
$custom_field_value .= '&swpm_id=' . SwpmMemberUtils::get_logged_in_members_id();
}
$custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value);
/* === PayPal Subscription Button Form === */
$output = '';
$output .= '<div class="swpm-button-wrapper swpm-pp-subscription-wrapper">';
if ($sandbox_enabled) {
$output .= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" ' . $window_target . '>';
} else {
$output .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" ' . $window_target . '>';
}
$output .= '<input type="hidden" name="cmd" value="_xclick-subscriptions" />';
$output .= '<input type="hidden" name="charset" value="utf-8" />';
$output .= '<input type="hidden" name="bn" value="TipsandTricks_SP" />';
$output .= '<input type="hidden" name="business" value="' . $paypal_email . '" />';
$output .= '<input type="hidden" name="currency_code" value="' . $payment_currency . '" />';
$output .= '<input type="hidden" name="item_number" value="' . $button_id . '" />';
$output .= '<input type="hidden" name="item_name" value="' . htmlspecialchars($button_cpt->post_title) . '" />';
//Check trial billing
if (!empty($trial_billing_cycle)) {
$output .= '<input type="hidden" name="a1" value="' . $trial_billing_amount . '" /><input type="hidden" name="p1" value="' . $trial_billing_cycle . '" /><input type="hidden" name="t1" value="' . $trial_billing_cycle_term . '" />';
}
//Main subscription billing
if (!empty($billing_cycle)) {
$output .= '<input type="hidden" name="a3" value="' . $billing_amount . '" /><input type="hidden" name="p3" value="' . $billing_cycle . '" /><input type="hidden" name="t3" value="' . $billing_cycle_term . '" />';
}
//Re-attempt on failure
if ($billing_reattempt != '') {
$output .= '<input type="hidden" name="sra" value="1" />';
}
//Reccurring times
if ($billing_cycle_count > 1) {
//do not include srt value if billing cycle count set to 1 or a negetive number.
$output .= '<input type="hidden" name="src" value="1" /><input type="hidden" name="srt" value="' . $billing_cycle_count . '" />';
} else {
if (empty($billing_cycle_count)) {
$output .= '<input type="hidden" name="src" value="1" />';
}
}
//Other required data
$output .= '<input type="hidden" name="no_shipping" value="1" />';
//Do not prompt for an address
$output .= '<input type="hidden" name="notify_url" value="' . $notify_url . '" />';
$output .= '<input type="hidden" name="return" value="' . $return_url . '" />';
$output .= '<input type="hidden" name="cancel_return" value="' . $cancel_url . '" />';
$output .= '<input type="hidden" name="custom" value="' . $custom_field_value . '" />';
//Filter to add additional payment input fields to the form (example: langauge code or country code etc).
$output .= apply_filters('swpm_pp_payment_form_additional_fields', '');
//Submit button
$button_image_url = get_post_meta($button_id, 'button_image_url', true);
if (!empty($button_image_url)) {
$output .= '<input type="image" src="' . $button_image_url . '" class="swpm-subscription-button-submit" alt="' . SwpmUtils::_('Subscribe Now') . '"/>';
} else {
//.........这里部分代码省略.........