Vendors membership plans style (my contribution)

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Membership Vendors membership plans style (my contribution)

Viewing 4 reply threads
  • Author
    Posts
    • #89163
      fethi.env
      Participant

      Hi,
      this is my contribution to add css class for plans and features

      Attachments:
      You must be logged in to view attached files.
    • #89168
      fethi.env
      Participant

      Modification: (attached files)

      code

      // file : class-wcfmvm.php
          /**
      	 * Create WCFMvm custom CSS
      	 */
      	function wcfmvm_create_membership_css() {
      		global $WCFM, $WCFMvm;
      		
      		$wcfm_membership_custom_css = wcfm_get_option('membership_setting_custom_css',''); //// =============================================> Add this 
              $wcfm_membership_options    = get_option('wcfm_membership_options');
      		$wcfmvm_color_options = array();
      		if( isset( $wcfm_membership_options['membership_color_settings'] ) ) $wcfmvm_color_options = $wcfm_membership_options['membership_color_settings'];
      		$color_options = $WCFMvm->wcfmvm_membership_color_setting_options();
      		$custom_color_data = $wcfm_membership_custom_css; //// =============================================> Add this 
      		$custom_button_color_data = '';
      		foreach( $color_options as $color_option_key => $color_option ) {
      		  $custom_color_data .= $color_option['element'] . '{ ' . "\n";
      			$custom_color_data .= "\t" . $color_option['style'] . ': ';
      			if( isset( $wcfmvm_color_options[ $color_option['name'] ] ) ) { $custom_color_data .= $wcfmvm_color_options[ $color_option['name'] ]; } else { $custom_color_data .= $color_option['default']; }
      			$custom_color_data .= ';' . "\n";
      			$custom_color_data .= '}' . "\n\n";
      			
      			if( in_array( $color_option_key, array( 'wcfmvm_field_button_color', 'wcfmvm_field_button_hover_color', 'wcfmvm_field_button_bg_color' ) ) ) {
      				$custom_button_color_data .= $color_option['element'] . '{ ' . "\n";
      				$custom_button_color_data .= "\t" . $color_option['style'] . ': ';
      				if( isset( $wcfmvm_color_options[ $color_option['name'] ] ) ) { $custom_button_color_data .= $wcfmvm_color_options[ $color_option['name'] ]; } else { $custom_button_color_data .= $color_option['default']; }
      				$custom_button_color_data .= ';' . "\n";
      				$custom_button_color_data .= '}' . "\n\n";
      			}
      			
      			if( isset( $color_option['element2'] ) && isset( $color_option['style2'] ) ) {
      				$custom_color_data .= $color_option['element2'] . '{ ' . "\n";
      				$custom_color_data .= "\t" . $color_option['style2'] . ': ';
      				if( isset( $wcfmvm_color_options[ $color_option['name'] ] ) ) { $custom_color_data .= $wcfmvm_color_options[ $color_option['name'] ]; } else { $custom_color_data .= $color_option['default']; }
      				$custom_color_data .= ';' . "\n";
      				$custom_color_data .= '}' . "\n\n";
      			}
      			
      			if( isset( $color_option['element3'] ) && isset( $color_option['style3'] ) ) {
      				$custom_color_data .= $color_option['element3'] . '{ ' . "\n";
      				$custom_color_data .= "\t" . $color_option['style3'] . ': ';
      				if( isset( $wcfmvm_color_options[ $color_option['name'] ] ) ) { $custom_color_data .= $wcfmvm_color_options[ $color_option['name'] ]; } else { $custom_color_data .= $color_option['default']; }
      				$custom_color_data .= ';' . "\n";
      				$custom_color_data .= '}' . "\n\n";
      			}
      			
      			if( isset( $color_option['element4'] ) && isset( $color_option['style4'] ) ) {
      				$custom_color_data .= $color_option['element4'] . '{ ' . "\n";
      				$custom_color_data .= "\t" . $color_option['style4'] . ': ';
      				if( isset( $wcfmvm_color_options[ $color_option['name'] ] ) ) { $custom_color_data .= $wcfmvm_color_options[ $color_option['name'] ]; } else { $custom_color_data .= $color_option['default']; }
      				$custom_color_data .= ';' . "\n";
      				$custom_color_data .= '}' . "\n\n";
      			}
      			
      			if( isset( $color_option['element5'] ) && isset( $color_option['style5'] ) ) {
      				$custom_color_data .= $color_option['element5'] . '{ ' . "\n";
      				$custom_color_data .= "\t" . $color_option['style5'] . ': ';
      				if( isset( $wcfmvm_color_options[ $color_option['name'] ] ) ) { $custom_color_data .= $wcfmvm_color_options[ $color_option['name'] ]; } else { $custom_color_data .= $color_option['default']; }
      				$custom_color_data .= ';' . "\n";
      				$custom_color_data .= '}' . "\n\n";
      			}
      		}
      		
      		$upload_dir      = wp_upload_dir();
      
      		$files = array(
      			array(
      				'key'     => 'wcfmvm_style_custom',
      				'base' 		=> $upload_dir['basedir'] . '/wcfm',
      				'file' 		=> 'wcfmvm-style-custom-' . time() . '.css',
      				'content' => $custom_color_data,
      			),
      			array(
      				'key'     => 'wcfmvm_style_custom_subscribe_button',
      				'base' 		=> $upload_dir['basedir'] . '/wcfm',
      				'file' 		=> 'wcfmvm-style-custom-subscribe-button-' . time() . '.css',
      				'content' => $custom_button_color_data,
      			)
      		);
      
      		$wcfmvm_style_custom = get_option( 'wcfmvm_style_custom' );
      		if(  $wcfmvm_style_custom && file_exists( trailingslashit( $upload_dir['basedir'] ) . 'wcfm/' . $wcfmvm_style_custom ) ) {
      			unlink( trailingslashit( $upload_dir['basedir'] ) . 'wcfm/' . $wcfmvm_style_custom );
      		}
      		
      		$wcfmvm_style_custom_subscribe_button = get_option( 'wcfmvm_style_custom_subscribe_button' );
      		if(  $wcfmvm_style_custom_subscribe_button && file_exists( trailingslashit( $upload_dir['basedir'] ) . 'wcfm/' . $wcfmvm_style_custom_subscribe_button ) ) {
      			unlink( trailingslashit( $upload_dir['basedir'] ) . 'wcfm/' . $wcfmvm_style_custom_subscribe_button );
      		}
      		
      		foreach ( $files as $file ) {
      			if ( wp_mkdir_p( $file['base'] ) ) {
      				if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
      					$wcfmvm_style_custom = $file['file'];
      					update_option( $file['key'], $file['file'] );
      					fwrite( $file_handle, $file['content'] );
      					fclose( $file_handle );
      				}
      			}
      		}
      		return $wcfmvm_style_custom;
      	}
      	
      /// file wcfmvm-controller-memberships-manage.php
      
                      // Update Membership Feature
      				if( isset( $wcfm_membership_manager_form_data['features'] ) ) {
      					update_post_meta( $new_membership_id, 'features', $wcfm_membership_manager_form_data['features'] );
      				} else {
      					update_post_meta( $new_membership_id, 'features', array() );
      				}
      				 // ======================================================================= here add this
      				 
      				 // Update Membership Feature css class name
      				if( isset( $wcfm_membership_manager_form_data['features_class'] ) ) {
      					update_post_meta( $new_membership_id, 'features_class', $wcfm_membership_manager_form_data['features_class'] );
      				} else {
      					update_post_meta( $new_membership_id, 'features_class', array() );
      				}
      				 
                      // Update Membership Style
      				if( isset( $wcfm_membership_manager_form_data['css_class_name'] ) ) {
      					update_post_meta( $new_membership_id, 'css_class_name', $wcfm_membership_manager_form_data['css_class_name'] );
      				} else {
      					update_post_meta( $new_membership_id, 'css_class_name', '' );
      				}	
      				
      				
      // file vendor_membership.php
      search for (2 time): 
      <div class="wcfm_membership_box_wrraper wcfm_membership_box_wrraper_<?php echo $wcfm_membership_id; ?> <?php if( $wcfm_membership_id == $featured_membership ) { echo 'wcfm_featured_membership_box_wrraper'; } ?>">	
      and add change it to
      <div class="wcfm_membership_box_wrraper wcfm_membership_box_wrraper_<?php echo $wcfm_membership_id; ?> <?php if( $wcfm_membership_id == $featured_membership ) { echo 'wcfm_featured_membership_box_wrraper'; } ?><?php echo $wcfm_membership->css_class_name; ?>">
      
      // file wcfmvm-view-memberships-settings.php
      
      after 
      $WCFM->wcfm_fields->wcfm_generate_form_field( $color_options_array );
      
      add
      
      $custom_css = wcfm_get_option( 'membership_setting_custom_css', '' );
                                  				$WCFM->wcfm_fields->wcfm_generate_form_field(apply_filters('membership_setting_custom_css_fields', array(
                                                    				                                                                                          sanitize_title('membership_setting_custom_css_fields') => array('label'       => 'Custom CSS', 
                                                    				                                                                                                                                'name'        => 'membership_setting_custom_css_fields', 
                                                    						                                                                                                                'type'        => 'textarea', 
                                                    				                                                                                                                                'class'       => 'wcfm-text wcfm_ele', 
                                                    				                                                                                                                                //'label_class' => 'wcfm_title', 
                                                    				                                                                                                                                'value'       => $custom_css),
                                                   				                                                                   )
                                                    				                                         )
                                                    				                          );
      
      search for 
      
      $features = (array) get_post_meta( $wcfm_membership_id, 'features', true );
      add after
      $feature_class = (array) get_post_meta( $wcfm_membership_id, 'features_class', true );
      
      search for
      $feature_val = 'x';
      
      add after
      $feature_class_val = "";
      
      search for 
      if( !empty( $features ) && isset( $features[$membership_feature_list['feature']] ) && !empty( $features[$membership_feature_list['feature']] ) ) $feature_val = $features[$membership_feature_list['feature']];
      add after
      if( !empty( $feature_class ) && isset( $feature_class[$membership_feature_list['feature']] ) && !empty( $feature_class[$membership_feature_list['feature']] ) ) $feature_class_val = $feature_class[$membership_feature_list['feature']];
      
      search for (next line)
      <div class="wcfm_membership_element">
      change it to
       
      
      // file : wcfmvm-controller-memberships-settings.php
      
      search for
      if( isset( $wcfm_membership_settings_form_data['wcfmvm_registration_static_fields'] ) ) {
      	  	wcfm_update_option( 'wcfmvm_registration_static_fields', $wcfm_membership_settings_form_data['wcfmvm_registration_static_fields'] );
      	  } else {
      	  	wcfm_update_option( 'wcfmvm_registration_static_fields', array() );
      	  }
                
      add after it this:		  
                // custom css
                if( isset( $wcfm_membership_settings_form_data['membership_setting_custom_css_fields'] ) ) {
      	  	wcfm_update_option( 'membership_setting_custom_css', $wcfm_membership_settings_form_data['membership_setting_custom_css_fields'] );               
      	  } else {
      	  	wcfm_update_option( 'membership_setting_custom_css', '' );
      	  }	
      
      search for :
      
      <?php
      							$WCFM->wcfm_fields->wcfm_generate_form_field( apply_filters( 'membership_setting_features_fields', array(  
      																																															"membership_features" => array( 'label' => __( 'Features List', 'wc-multivendor-membership' ), 'type' => 'multiinput', 'value' => $membership_feature_lists, 'options' => array(
      																																																'feature' => array( 'label' => __( 'Feature', 'wc-multivendor-membership' ), 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title' ),
      																																																'help'    => array( 'label' => __( 'Help Message', 'wc-multivendor-membership' ), 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title'  )
      																																					) ) ) ) );
      						?>
      
      replace it by 
      
      <?php
      							$WCFM->wcfm_fields->wcfm_generate_form_field( apply_filters( 'membership_setting_features_fields', array(  
      																																															"membership_features" => array( 'label' => __( 'Features List', 'wc-multivendor-membership' ), 'type' => 'multiinput', 'value' => $membership_feature_lists, 'options' => array(
      																																																'feature' => array( 'label' => __( 'Feature', 'wc-multivendor-membership' ), 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title' ),
      																																																'help'    => array( 'label' => __( 'Help Message', 'wc-multivendor-membership' ), 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title'  ),
                                                                                                                                                                                                      'text_color'    => array( 'label' => __( 'Text color code', 'wc-multivendor-membership' ), 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title'  )
      																																					) ) ) ) );
      						?>
      
      // file wcfmvm-view-memberships-manage.php
      
      after 1st :
      <!-- end collapsible -->
      
      add this
      <!-- collapsible -->
                  <div class="wcfm-tabWrap">
                      <div class="page_collapsible" id="memberships_style_head">
                          <label class="wcfmfa fa-sun"></label>
                              <?php _e('Style', 'wc-multivendor-membership'); ?>
                      </div>
                      <div class="wcfm-container">
                          <div id="memberships_style_expander" class="wcfm-content">
                              <?php
                                  $WCFM->wcfm_fields->wcfm_generate_form_field(apply_filters('membership_manager_fields_style', array(
                                                                                                                        sanitize_title('css_class_name') => array('label'       => 'CSS Class name', 
                                                                                                                                                                                                       'name'        => 'css_class_name', 
                                                                                                                                                                                                       'type'        => 'text', 
                                                                                                                                                                                                       'class'       => 'wcfm-text wcfm_ele', 
                                                                                                                                                                                                       'label_class' => 'wcfm_title', 
                                                                                                                                                                                                       'value'       => $css_class_name),
                                                                                                                      )
                                                                                             )
                                                                              );
                              ?>
                          </div>
                      </div>
                      <div class="wcfm_clearfix"></div>
                      <!-- end collapsible -->	  
      				
      search for 
      $features = array();
      
      add  after
      $features_class = array();
      
      search for 
      $features = (array) get_post_meta($membership_id, 'features', true);
      add after
      $features_class = (array) get_post_meta($membership_id, 'features_class', true);
      
      search for 
      $feature_val       = $features[$membership_feature_list['feature']];
      
      add after
      $feature_class_val = $features_class[$membership_feature_list['feature']];
      
      search for 
      sanitize_title($membership_feature_list['feature']) => array('label' => $membership_feature_list['feature'], 'name' => 'features[' . $membership_feature_list['feature'] . ']', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title', 'value' => $feature_val),
      add after
      sanitize_title($membership_feature_list['feature'].'_class') => array('label' => $membership_feature_list['feature'].' css class', 'name' => 'features_class[' . $membership_feature_list['feature'] . ']', 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title', 'value' => $feature_class_val),
      Attachments:
      You must be logged in to view attached files.
    • #91274
      adrian.petcu2011
      Participant

      Good, useful and honorable intention. If it would work.
      But in file : wcfmvm-controller-memberships-settings.php, the sequence below isn’t there:
      <?php
      $WCFM->wcfm_fields->wcfm_generate_form_field( apply_filters( ‘membership_setting_features_fields’, array( “membership_features” => array( ‘label’ => __( ‘Features List’, ‘wc-multivendor-membership’ ), ‘type’ => ‘multiinput’, ‘value’ => $membership_feature_lists, ‘options’ => array(
      ‘feature’ => array( ‘label’ => __( ‘Feature’, ‘wc-multivendor-membership’ ), ‘type’ => ‘text’, ‘class’ => ‘wcfm-text wcfm_ele’, ‘label_class’ => ‘wcfm_title’ ),
      ‘help’ => array( ‘label’ => __( ‘Help Message’, ‘wc-multivendor-membership’ ), ‘type’ => ‘text’, ‘class’ => ‘wcfm-text wcfm_ele’, ‘label_class’ => ‘wcfm_title’ )
      ) ) ) ) );
      ?>
      the same for the file wcfmvm-view-memberships-settings.php

    • #93679
      fethi.env
      Participant

      Hi
      you can add hooks in this topic & I will send to you an addon
      https://wclovers.com/forums/topic/add-some-hooks/

    • #93680
      fethi.env
      Participant

      This is the last version with that hooks

      Attachments:
      You must be logged in to view attached files.
Viewing 4 reply threads
  • The topic ‘Vendors membership plans style (my contribution)’ is closed to new replies.