Пример #1
0
function wdeb_supporter_themes_not_enabled()
{
    if (class_exists('ProSites')) {
        $ps_modules = ProSites::get_setting('modules_enabled');
        $ps_modules = $ps_modules ? $ps_modules : array();
        $has_themes = in_array('ProSites_Module_PremiumThemes', $ps_modules);
    } else {
        $has_themes = function_exists('supporter_themes_page');
    }
    return !(function_exists('is_supporter') && is_supporter() && $has_themes);
}
function wdeb_supporter_themes_not_enabled()
{
    if (class_exists('ProSites')) {
        global $psts;
        if ($psts && !empty($psts->version) && version_compare($psts->version, '3.3.3', '>=')) {
            $has_themes = false;
        } else {
            $ps_modules = ProSites::get_setting('modules_enabled');
            $ps_modules = $ps_modules ? $ps_modules : array();
            $has_themes = in_array('ProSites_Module_PremiumThemes', $ps_modules);
        }
    } else {
        $has_themes = function_exists('supporter_themes_page');
    }
    return !(function_exists('is_supporter') && is_supporter() && $has_themes);
}
Пример #3
0
 private static function render_pricing_columns($columns, $blog_id = false, $echo = false)
 {
     global $psts;
     $content = '';
     $periods = (array) $psts->get_setting('enabled_periods');
     $show_periods = 2 <= count($periods) ? true : false;
     $show_first_column = $show_periods && 'option2' != $psts->get_setting('pricing_table_period_position', 'option1');
     $total_columns = $show_first_column ? count($columns) : count($columns) - 1;
     $total_width = 100.0;
     $total_width -= 6.0;
     // account for extra space around featured plan
     $column_width = $total_width / $total_columns;
     $feature_width = $column_width + 6.0;
     $normal_style = 'width: ' . $column_width . '%; ';
     $feature_style = 'width: ' . $feature_width . '%; ';
     $column_keys = array_keys($columns[0]);
     $show_pricing_table = in_array('title', $column_keys);
     $show_feature_table = in_array('sub_title', $column_keys);
     $show_buy_buttons = in_array('button', $column_keys);
     $add_coupon = in_array('coupon', $column_keys);
     //			$show_buy_buttons = false;
     foreach ($columns as $key => $column) {
         $style = true === $column['featured'] ? $feature_style : $normal_style;
         $col_class = true === $column['featured'] ? ' featured' : '';
         $level_id = isset($column['level_id']) ? $column['level_id'] : 0;
         // Has a chosen plan been given? Note: Period should already be set.
         if (!empty(self::$selected_level) && 0 != $level_id) {
             $col_class = $level_id == (int) self::$selected_level ? $col_class . ' chosen-plan' : $col_class;
         }
         // Remove the 0 column
         $override = '';
         if (empty($level_id)) {
             $override = $show_first_column ? '' : 'hidden';
             $col_class .= ' ' . $override;
             //continue;
         }
         $content .= '<ul class="pricing-column psts-level-' . esc_attr($level_id) . ' ' . esc_attr($col_class) . '" style="' . esc_attr($style) . '">';
         if ($show_pricing_table) {
             if (empty($column['title'])) {
                 $content .= '<li class="title no-title"></li>';
             } else {
                 $content .= '<li class="title">' . ProSites::filter_html($column['title']) . '</li>';
             }
             $content .= '<li class="summary ' . $override . '">' . ProSites::filter_html($column['summary']) . '</li>';
         }
         if ($show_feature_table) {
             $features_class = $show_pricing_table ? '' : 'no-header';
             if (empty($column['sub_title'])) {
                 $content .= '<li class="sub-title no-title ' . $features_class . '"></li>';
             } else {
                 $content .= '<li class="sub-title ' . $features_class . '">' . ProSites::filter_html($column['sub_title']) . '</li>';
             }
             $content .= '<li><ul class="feature-section">';
             foreach ($column['features'] as $index => $feature) {
                 $alt = isset($feature['alt']) && true == $feature['alt'] ? 'alternate' : '';
                 $content .= '<li class="feature feature-' . $index . ' ' . $alt . '"><div class="feature-content">';
                 if (isset($feature['name']) && !empty($feature['name'])) {
                     $content .= '<div class="feature-name">' . ProSites::filter_html($feature['name']) . '</div>';
                 }
                 if (isset($feature['indicator']) && !empty($feature['indicator'])) {
                     $content .= '<div class="feature-indicator">' . ProSites::filter_html($feature['indicator']) . '</div>';
                 }
                 if (isset($feature['text']) && !empty($feature['text'])) {
                     $content .= '<div class="feature-text">' . ProSites::filter_html($feature['text']) . '</div>';
                 }
                 $content .= '</div></li>';
             }
             $content .= '</ul></li>';
         }
         if ($show_buy_buttons) {
             if (empty($column['button'])) {
                 if ($add_coupon && 'option1' == $psts->get_setting('pricing_table_coupon_position', 'option1')) {
                     $content .= '<li class="coupon">';
                     $content .= '<div class="coupon-box">';
                     $content .= '<input type="text" name="apply-coupon" placeholder="' . __('Enter coupon', 'psts') . '" />';
                     $content .= '<a name="apply-coupon-link" class="apply-coupon-link">' . $column['coupon'] . '</a>';
                     $content .= '</div>';
                     $content .= '</li>';
                 } else {
                     $content .= '<li class="button-box no-button"></li>';
                 }
             } else {
                 $content .= '<li class="button-box">' . $column['button'] . '</li>';
             }
         }
         $content .= '</ul>';
     }
     $allow_free = $psts->get_setting('free_signup');
     $style = 'margin-left: ' . $column_width . '%; ';
     $style .= 'width: ' . (100 - $column_width) . '%; ';
     $content = apply_filters('psts_checkout_before_free', $content, $blog_id, $style);
     if ($allow_free) {
         $content .= self::render_free($style, $blog_id);
     }
     $content = apply_filters('psts_checkout_after_free', $content, $blog_id, $style);
     if ($echo) {
         echo $content;
     }
     return $content;
 }
 /**
  * Update Pending reason for Payment
  *
  * @param $blog_id
  * @param $payment_status
  * @param $pending_reason
  * @param $payerid
  */
 private static function update_pending_reason($blog_id, $payment_status, $pending_reason = '', $payerid, $pending_profile = '')
 {
     global $psts, $wpdb;
     $psts->log_action($blog_id, sprintf(__('PayPal response: Last payment is pending (%s). Reason: %s', 'psts'), $payment_status, $pending_reason) . '. Payer ID: ' . $payerid);
     //Store Payment status and reason in pro site meta
     $payment_details = array('payment_status' => $payment_status, 'pending_reason' => !empty($pending_reason) ? self::$pending_str[$pending_reason] : $pending_profile);
     update_user_meta(get_current_user_id(), 'psts_payment_details', $payment_details);
     /** @Todo: Add condition, to avoid it running for every update query
      **/
     //Update Gateway, as site is under trial gateway currently
     $wpdb->update($wpdb->base_prefix . 'pro_sites', array('gateway' => self::get_slug()), array('blog_ID' => $blog_id));
     //Remove tiraling status
     $meta = ProSites::get_prosite_meta($blog_id);
     if (!empty($meta) && !empty($meta['trialing'])) {
         $meta['trialing'] = 0;
         ProSites::update_prosite_meta($blog_id, $meta);
     }
 }
 /**
  * This is where the default menu items are set.
  * Menu items are set as an array of menu items.
  * Each item is an associative array, with these values:
  * 	- "check_callback" - Custom PHP callback that will be called prior
  * 		to rendering the item, in order to determine if the item
  * 		should be displayed at all.
  * 	- "capability" - Minimum required user capability to display the
  * 		menu item. This will be checked prior to "check_callback".
  * 	- "url" - Administrative page url (e.g. edit.php).
  * 	- "icon" - Full menu icon URL.
  * 	- "title" - Main text for the menu item.
  * 	- "help" - Will be shown as tooltip and (optionally) transient
  * 		help text screen for the menu item.
  *
  * Plugins can register their own menu items by hooking into
  * "wdeb_menu_items" filter.
  */
 function easy_mode_menu()
 {
     $pro_href = $pro_title = false;
     if (class_exists('ProSites')) {
         // Official
         $pro_href = 'admin.php?page=psts-checkout';
         $pro_title = ProSites::get_setting('rebrand');
     } else {
         if (class_exists('ProBlogs')) {
             // Beta
             $pro_href = 'admin.php?page=pblgs-checkout';
             $pro_title = ProBlogs::get_setting('rebrand');
         } else {
             if (function_exists('is_supporter')) {
                 // Old
                 $pro_href = 'supporter.php';
                 $pro_title = __('Supporter', 'wdeb');
             }
         }
     }
     return array(array('check_callback' => false, 'capability' => false, 'url' => 'index.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/home.png', 'title' => __('Dashboard', 'wdeb'), 'help' => __('Your start page', 'wdeb')), array('check_callback' => false, 'capability' => 'edit_posts', 'url' => 'post-new.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/new-post.png', 'title' => __('New Post', 'wdeb'), 'help' => __('Create a new post', 'wdeb')), array('check_callback' => false, 'capability' => 'edit_posts', 'url' => 'edit.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/posts.png', 'title' => __('My Posts', 'wdeb'), 'help' => __('Edit your posts', 'wdeb')), array('check_callback' => false, 'capability' => 'edit_pages', 'url' => 'post-new.php?post_type=page', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/new-page.png', 'title' => __('New Page', 'wdeb'), 'help' => __('Create a new page', 'wdeb')), array('check_callback' => false, 'capability' => 'edit_pages', 'url' => 'edit.php?post_type=page', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/pages.png', 'title' => __('My Pages', 'wdeb'), 'help' => __('Edit your pages', 'wdeb')), array('check_callback' => false, 'capability' => 'edit_posts', 'url' => 'edit-comments.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/comments.png', 'title' => __('Comments', 'wdeb'), 'help' => __('Moderate your comments', 'wdeb')), array('check_callback' => 'wdeb_supporter_themes_enabled', 'capability' => 'switch_themes', 'url' => 'themes.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/free-themes.png', 'title' => __('Free Themes', 'wdeb'), 'help' => __('Change your site appearance', 'wdeb')), array('check_callback' => 'wdeb_supporter_themes_enabled', 'capability' => 'switch_themes', 'url' => 'themes.php?page=premium-themes', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/premium-themes.png', 'title' => __('Premium Themes', 'wdeb'), 'help' => __('Change your site appearance', 'wdeb')), array('check_callback' => 'wdeb_supporter_themes_not_enabled', 'capability' => 'switch_themes', 'url' => 'themes.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/free-themes.png', 'title' => __('Manage Themes', 'wdeb'), 'help' => __('Change your site appearance', 'wdeb')), array('check_callback' => false, 'capability' => 'edit_theme_options', 'url' => 'widgets.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/edit-themes.png', 'title' => __('Customize Design', 'wdeb'), 'help' => __('Personalize your site', 'wdeb')), array('check_callback' => 'wdeb_not_supporter', 'capability' => 'manage_options', 'url' => $pro_href, 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/supporter.png', 'title' => $pro_title, 'help' => __('Support us!', 'wdeb')), array('check_callback' => false, 'capability' => false, 'url' => 'profile.php', 'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/profiles.png', 'title' => __('Profile', 'wdeb'), 'help' => __('Edit your profile information', 'wdeb')));
 }
Пример #6
0
 public static function set_trial($blog_id, $value)
 {
     $meta = ProSites::get_prosite_meta($blog_id);
     if (empty($meta)) {
         $meta = array();
     }
     $meta['trialing'] = $value;
     ProSites::update_prosite_meta($blog_id, $meta);
 }
Пример #7
0
	function install() {
		global $wpdb, $current_site;

		//check if multisite is installed
		if ( ! is_multisite() ) {
			$this->trigger_install_error( __( 'WordPress multisite is required to run this plugin. <a target="_blank" href="http://codex.wordpress.org/Create_A_Network">Create a network</a>.', 'psts' ), E_USER_ERROR );
		}

		//rename tables if upgrading from old supporter
		if ( get_site_option( "supporter_installed" ) == "yes" ) {
			$wpdb->query( "RENAME TABLE `{$wpdb->base_prefix}supporters` TO `{$wpdb->base_prefix}pro_sites`" );
			$wpdb->query( "RENAME TABLE `{$wpdb->base_prefix}supporter_signup_stats` TO `{$wpdb->base_prefix}pro_sites_signup_stats`" );
			$wpdb->query( "RENAME TABLE `{$wpdb->base_prefix}supporter_daily_stats` TO `{$wpdb->base_prefix}pro_sites_daily_stats`" );
			delete_site_option( "supporter_installed" );
		}

		if( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
			define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', false );
		}

		$table1 = "CREATE TABLE {$wpdb->base_prefix}pro_sites (
		  blog_ID bigint(20) NOT NULL,
		  level int(3) NOT NULL DEFAULT 1,
		  expire bigint(20) NOT NULL,
		  gateway varchar(25) NULL DEFAULT '',
		  term varchar(25) NULL DEFAULT NULL,
		  amount varchar(10) NULL DEFAULT NULL,
		  is_recurring tinyint(1) NULL DEFAULT 1,
		  meta longtext NOT NULL,
		  identifier varchar(50) NULL,
		  PRIMARY KEY  (blog_ID),
		  KEY  (blog_ID,level,expire)
		);";

		$table2 = "CREATE TABLE {$wpdb->base_prefix}pro_sites_signup_stats (
		  action_ID bigint(20) unsigned NOT NULL auto_increment,
		  blog_ID bigint(20) NOT NULL,
		  action varchar(20) NOT NULL,
		  time_stamp DATE NOT NULL,
		  PRIMARY KEY  (action_ID)
		);";

		$table3 = "CREATE TABLE {$wpdb->base_prefix}pro_sites_daily_stats (
		  id bigint(20) unsigned NOT NULL auto_increment,
		  date DATE NOT NULL,
		  supporter_count int(10) NOT NULL DEFAULT 0,
		  expired_count int(10) NOT NULL DEFAULT 0,
		  term_count_1 int(10) NOT NULL DEFAULT 0,
		  term_count_3 int(10) NOT NULL DEFAULT 0,
		  term_count_12 int(10) NOT NULL DEFAULT 0,
		  term_count_manual int(10) NOT NULL DEFAULT 0,
		  level_count_1 int(10) NOT NULL DEFAULT 0,
		  level_count_2 int(10) NOT NULL DEFAULT 0,
		  level_count_3 int(10) NOT NULL DEFAULT 0,
		  level_count_4 int(10) NOT NULL DEFAULT 0,
		  level_count_5 int(10) NOT NULL DEFAULT 0,
		  level_count_6 int(10) NOT NULL DEFAULT 0,
		  level_count_7 int(10) NOT NULL DEFAULT 0,
		  level_count_8 int(10) NOT NULL DEFAULT 0,
		  level_count_9 int(10) NOT NULL DEFAULT 0,
		  level_count_10 int(10) NOT NULL DEFAULT 0,
		  PRIMARY KEY  (id)
		);";

		$table4 = "CREATE TABLE {$wpdb->base_prefix}pro_sites_transactions (
		  id bigint(20) unsigned NOT NULL auto_increment,
		  transaction_id varchar(255) NOT NULL,
		  transaction_date DATE NOT NULL,
		  items longtext NOT NULL,
		  total decimal(13,4) NOT NULL DEFAULT 0,
		  sub_total decimal(13,4) NOT NULL DEFAULT 0,
		  tax_amount decimal(13,4) NOT NULL DEFAULT 0,
		  tax_percentage decimal(4,2) NOT NULL DEFAULT 0,
		  country varchar(3) NULL,
		  currency varchar(3) NULL,
		  meta longtext NULL,
		  PRIMARY KEY  (id),
		  KEY  (id, transaction_id)
		);";

		if ( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) || ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && ! DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
			dbDelta( $table1 );
			dbDelta( $table2 );
			dbDelta( $table3 );
			dbDelta( $table4 );
		}

		// add stats cron job action only to main site (or it may be running all the time!)
		switch_to_blog( $current_site->blog_id );
		if ( ! wp_next_scheduled( 'psts_process_stats' ) ) {
			//get end of day
			$time = strtotime( date( "Y-m-d 23:50:00" ) );
			wp_schedule_event( $time, 'daily', 'psts_process_stats' );
		}
		restore_current_blog();

		//our default settings
		$default_settings = ProSites::get_default_settings_array();

		$settings         = wp_parse_args( ( array ) get_site_option( 'psts_settings' ), $default_settings );
		update_site_option( 'psts_settings', $settings );

		//default level
		$default_levels = array(
			1 => array(
				'name'     => __( 'Pro', 'psts' ),
				'price_1'  => get_site_option( "supporter_1_whole_cost" ) . '.' . get_site_option( "supporter_1_partial_cost" ),
				'price_3'  => get_site_option( "supporter_3_whole_cost" ) . '.' . get_site_option( "supporter_3_partial_cost" ),
				'price_12' => get_site_option( "supporter_12_whole_cost" ) . '.' . get_site_option( "supporter_12_partial_cost" )
			)
		);
		if ( ! get_site_option( 'psts_levels' ) ) {
			add_site_option( 'psts_levels', $default_levels );
		}

		//create a checkout page if not existing
		add_action( 'init', array( &$this, 'create_checkout_page' ) );

		//3.4.3.8 upgrade - fixes permanent upgrades that got truncated on 32 bit systems due to (int) casting
		if ( version_compare( $this->get_setting( 'version' ), '3.4.3.7', '<=' ) ) {
			$wpdb->query( "UPDATE {$wpdb->base_prefix}pro_sites SET expire = '9999999999' WHERE expire = '1410065407'" );
		}

		//3.5 upgrade - modify pro_sites table
		if ( version_compare( $this->get_setting( 'version' ), '3.5', '<=' ) ) {
			// Using dbDelta above, but add other code here.
			//$wpdb->query( "ALTER TABLE {$wpdb->base_prefix}pro_sites ADD meta longtext NOT NULL" );
		}

		$this->update_setting( 'version', $this->version );
	}