register_control_type( 'FS_Customizer_Upsell_Control' ); parent::__construct( $manager, $id, $args ); } /** * Enqueue resources for the control. */ public function enqueue() { fs_enqueue_local_style( 'fs_customizer', 'customizer.css' ); } /** * Json conversion */ public function to_json() { $pricing_cta = esc_html( $this->fs->get_pricing_cta_label() ) . '  ' . ( is_rtl() ? '←' : '➤' ); parent::to_json(); $this->json['button_text'] = $pricing_cta; $this->json['button_url'] = $this->fs->is_in_trial_promotion() ? $this->fs->get_trial_url() : $this->fs->get_upgrade_url(); $api = FS_Plugin::is_valid_id( $this->fs->get_bundle_id() ) ? $this->fs->get_api_bundle_scope() : $this->fs->get_api_plugin_scope(); // Load features. $pricing = $api->get( $this->fs->add_show_pending( "pricing.json" ) ); if ( $this->fs->is_api_result_object( $pricing, 'plans' ) ) { // Add support features. if ( is_array( $pricing->plans ) && 0 < count( $pricing->plans ) ) { $support_features = array( 'kb' => 'Help Center', 'forum' => 'Support Forum', 'email' => 'Priority Email Support', 'phone' => 'Phone Support', 'skype' => 'Skype Support', 'is_success_manager' => 'Personal Success Manager', ); for ( $i = 0, $len = count( $pricing->plans ); $i < $len; $i ++ ) { if ( 'free' == $pricing->plans[$i]->name ) { continue; } if ( ! isset( $pricing->plans[ $i ]->features ) || ! is_array( $pricing->plans[ $i ]->features ) ) { $pricing->plans[$i]->features = array(); } foreach ( $support_features as $key => $label ) { $key = ( 'is_success_manager' !== $key ) ? "support_{$key}" : $key; if ( ! empty( $pricing->plans[ $i ]->{$key} ) ) { $support_feature = new stdClass(); $support_feature->title = $label; $pricing->plans[ $i ]->features[] = $support_feature; } } } } } $this->json['plans'] = $pricing->plans; $this->json['strings'] = array( 'plan' => $this->fs->get_text_x_inline( 'Plan', 'as product pricing plan', 'plan' ), ); } /** * Control content */ public function content_template() { ?>
<# if ( data.plans ) { #> <# } #>