Advertisement
rejuancse

menu-settings

Sep 18th, 2018
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 34.55 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3.     exit; // Exit if accessed directly
  4. }
  5.  
  6. require_once( ABSPATH.'wp-includes/pluggable.php' );
  7.  
  8. // Settings Option Generator
  9. function wpneo_crowdfunding_settings_generate_field( $arr ){
  10.  
  11.     $output = '';
  12.     $output .= '<table class="form-table">';
  13.     $output .= '<tbody>';
  14.  
  15.     foreach ($arr as $value) {
  16.         if(isset( $value['type'] )){
  17.             switch ( $value['type'] ) {
  18.  
  19.                 case 'dropdown':
  20.                     $output .= '<tr>';
  21.                     $output .= '<th><label for="'.$value['id'].'">'.$value["label"].'</label></th>';
  22.                     $output .= '<td>';
  23.                     $multiple = '';
  24.                     if(isset($value['multiple'])){ $multiple = 'multiple'; }
  25.                     $output .= '<select id="'.$value['id'].'" name="'.$value['id'].'" '.$multiple.'>';
  26.                     $campaign_status = get_option( $value['id'] );
  27.                     if(!empty($value['option'])){
  28.                         foreach ( $value['option'] as $key => $val ){
  29.                             $output .= '<option value="'.$key.'" '.( $key == $campaign_status ? "selected":"" ).'>'.$val.'</option>';
  30.                         }
  31.                     }
  32.                     $output .= ' </select>';
  33.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  34.                     $output .= '</td>';
  35.                     $output .= '</tr>';
  36.                     break;
  37.  
  38.                 case 'multiple':
  39.                     $output .= '<tr>';
  40.                     $output .= '<th><label for="'.$value['id'].'">'.$value["label"].'</label></th>';
  41.                     $output .= '<td>';
  42.                     $multiple = '';
  43.                     if(isset($value['multiple'])){ $multiple = 'multiple'; }
  44.                     $output .= '<select style="height:190px;" id="'.$value['id'].'" name="'.$value['id'].'[]" '.$multiple.'>';
  45.                     $campaign_status = get_option( $value['id'] );
  46.                     if(!empty($value['option'])){
  47.                         foreach ( $value['option'] as $val ){
  48.                             if( !empty($campaign_status) && is_array($campaign_status) ){
  49.                                 if( in_array( $val , $campaign_status ) ){
  50.                                     $output .= '<option value="'.$val.'" selected>'.$val.'</option>';
  51.                                 }else{
  52.                                     $output .= '<option value="'.$val.'">'.$val.'</option>';
  53.                                 }
  54.                             }else{
  55.                                 $output .= '<option value="'.$val.'">'.$val.'</option>';
  56.                             }
  57.                         }
  58.                     }
  59.                     $output .= ' </select>';
  60.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  61.                     $output .= '</td>';
  62.                     $output .= '</tr>';
  63.                     break;
  64.  
  65.                 case 'text':
  66.                     $output .= '<tr>';
  67.                     $output .= '<th><label for="'.$value['id'].'">'.$value['label'].'</label></th>';
  68.                     $output .= '<td>';
  69.                     $var = get_option( $value['id'] );
  70.                     $default_value = ( isset($value["value"])) ? $value["value"] : '';
  71.                     $output .= '<input type="text" id="'.$value['id'].'" value="'.( $var ? $var : $default_value ).'" name="'.$value['id'].'">';
  72.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  73.                     $output .= '</td>';
  74.                     $output .= '</tr>';
  75.                     break;
  76.  
  77.                 case 'password':
  78.                     $output .= '<tr>';
  79.                     $output .= '<th><label for="'.$value['id'].'">'.$value['label'].'</label></th>';
  80.                     $output .= '<td>';
  81.                     $var = get_option( $value['id'] );
  82.                     $output .= '<input type="password" id="'.$value['id'].'" value="'.( $var ? $var : $value["value"] ).'" name="'.$value['id'].'">';
  83.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  84.                     $output .= '</td>';
  85.                     $output .= '</tr>';
  86.                     break;
  87.  
  88.                 case 'textarea':
  89.                     $output .= '<tr>';
  90.                     $output .= '<th><label for="'.$value['id'].'">'.$value['label'].'</label></th>';
  91.                     $output .= '<td>';
  92.                     $var = get_option( $value['id'] );
  93.                     $output .= '<textarea name="'.$value['id'].'" id="'.$value['id'].'">'.( $var ? $var : $value["value"] ).'</textarea>';
  94.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  95.                     $output .= '</td>';
  96.                     $output .= '</tr>';
  97.                     break;
  98.  
  99.                 case 'number':
  100.                     $output .= '<tr>';
  101.                     $output .= '<th scope="row"><label for="'.$value["id"].'">'.$value["label"].'</label></th>';
  102.                     $output .= '<td>';
  103.                     $data = '';
  104.                     $var = get_option( $value["id"] );
  105.                     if( isset($value["min"]) != "" ){ $data .= 'min="'.$value["min"].'"'; }
  106.                     if( isset($value["max"]) != "" ){ $data .= ' max="'.$value["max"].'"'; }
  107.                     $output .= '<input type="number" value="'.( $var ? $var : $value["value"]).'" '.$data.' name="'.$value["id"].'" />';
  108.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  109.                     $output .= '</td>';
  110.                     $output .= '</tr>';
  111.                     break;
  112.  
  113.                 case 'radio':
  114.                     $output .= '<tr>';
  115.                     $output .= '<th scope="row"><label for="'.$value["id"].'">'.$value["label"].'</label></th>';
  116.                     $output .= '<td>';
  117.                     $data = '';
  118.                     $var = get_option( $value["id"] );
  119.                     if( ! $var ){ $var =  ! empty($value["value"]) ? $value["value"] : ''  ; }
  120.                     if(!empty($value['option'])){
  121.                         foreach( $value['option'] as $key => $val ){
  122.                             $cehcked = ($key == $var) ? ' checked="checked" ' : '';
  123.                             $output .= '<label> <input type="radio" name="'.$value['id'].'" value="'.$key.'" '.$cehcked.' > '.$val.' </label> <br>';
  124.                         }
  125.                     }
  126.  
  127.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  128.  
  129.                     $output .= '</td>';
  130.                     $output .= '</tr>';
  131.                     break;
  132.  
  133.                 case 'checkbox':
  134.                     $output .= '<tr>';
  135.                     $output .= '<th><label for="'.$value['id'].'">'.$value['label'].'</label></th>';
  136.                     $output .= '<td>';
  137.                     $var = get_option( $value['id'] );
  138.                     $output .= '<label><input type="checkbox" name="'.$value['id'].'" id="'.$value['id'].'" value="true" '.($var=="true"?"checked='checked'":"").'/>';
  139.                     if(isset($value['desc'])){ $output .= $value['desc']; }
  140.                     $output .= '</label>';
  141.                     $output .= '</td>';
  142.                     $output .= '</tr>';
  143.                     break;
  144.  
  145.                 case 'seperator':
  146.                     $output .= '<tr>';
  147.                     $output .= '<th colspan="2">';
  148.                     if( isset($value['label']) ){ $output .= '<h2>'.$value["label"].'</h2>'; }
  149.                     if( isset($value['desc']) ){ $output .= '<p>'.$value['desc'].'</p>'; }
  150.                     if( isset($value['top_line']) != '' ){ $output .= '<hr>'; }
  151.                     $output .= '</th>';
  152.                     $output .= '</tr>';
  153.                     break;
  154.  
  155.                 case 'color':
  156.                     $output .= '<tr>';
  157.                     $output .= '<th><label for="'.$value['id'].'">'.$value['label'].'</label></th>';
  158.                     $output .= '<td>';
  159.                     $var = get_option( $value['id'] );
  160.                     if(!$var){ $var = $value['value']; }
  161.                     $output .= '<input type="text" name="'.$value['id'].'" value="'.$var.'" id="'.$value['id'].'" class="wpneo-color-field" >';
  162.                     if(isset($value['desc'])){ $output .= '<p>'.$value['desc'].'</p>'; }
  163.                     $output .= '</td>';
  164.                     $output .= '</tr>';
  165.                     break;
  166.  
  167.                 case 'hidden':
  168.                     $output .= '<tr>';
  169.                     $output .= '<th colspan="2">';
  170.                     $output .= '<input type="hidden" value="'.$value["value"].'" name="'.$value['id'].'">';
  171.                     $output .= '</th>';
  172.                     $output .= '</tr>';
  173.                     break;
  174.  
  175.                 default:
  176.                     # code...
  177.                    break;
  178.             }
  179.         }
  180.     }
  181.     $output .= '</tbody>';
  182.     $output .= '</table>';
  183.  
  184.     return $output;
  185. }
  186.  
  187.  
  188. /**
  189.  * Display a custom menu page
  190.  */
  191. function neo_crowdfunding_menu_page(){
  192.     // Settings Tab With slug and Display name
  193.     $tabs = apply_filters('wpneo_crowdfunding_settings_panel_tabs', array(
  194.             'general'   =>
  195.                 array(
  196.                     'tab_name' => __('General Settings','wp-crowdfunding'),
  197.                     'load_form_file' => WPNEO_CROWDFUNDING_DIR_PATH.'admin/includes-tab/tab-general.php'
  198.                 ),
  199.             'woocommerce'   =>
  200.                 array(
  201.                     'tab_name' => __('WooCommerce Settings','wp-crowdfunding'),
  202.                     'load_form_file' => WPNEO_CROWDFUNDING_DIR_PATH.'admin/includes-tab/tab-woocommerce.php'
  203.                 ),
  204.             'style'   =>
  205.                 array(
  206.                     'tab_name' => __('Style','wp-crowdfunding'),
  207.                     'load_form_file' => WPNEO_CROWDFUNDING_DIR_PATH.'admin/includes-tab/tab-style.php'
  208.                 ),
  209.         )
  210.     );
  211.  
  212.     $current_page = 'general';
  213.     if( ! empty($_GET['tab']) ){
  214.         $current_page = sanitize_text_field($_GET['tab']);
  215.     }
  216.  
  217.     // Print the Tab Title
  218.     echo '<h2 class="nav-tab-wrapper">';
  219.     foreach( $tabs as $tab => $name ){
  220.         $class = ( $tab == $current_page ) ? ' nav-tab-active' : '';
  221.         echo "<a class='nav-tab$class' href='?page=wpneo-crowdfunding&tab=$tab'>{$name['tab_name']}</a>";
  222.     }
  223.     echo '</h2>';
  224.     ?>
  225.  
  226.     <form id="neo-crowdfunding" role="form" method="post" action="">
  227.         <?php
  228.         //Load tab file
  229.         $request_file = $tabs[$current_page]['load_form_file'];
  230.         $default_file = WPNEO_CROWDFUNDING_DIR_PATH.'admin/includes-tab/tab-general.php';
  231.  
  232.         if (array_key_exists(trim(esc_attr($current_page)), $tabs)){
  233.             if (file_exists($default_file)){
  234.                 include_once $request_file;
  235.             }else{
  236.                 include_once $default_file;
  237.             }
  238.         }else {
  239.             include_once $default_file;
  240.         }
  241.  
  242.         wp_nonce_field('wpneo_settings_page_action', 'wpneo_settings_page_nonce_field');
  243.         submit_button(null,'primary','wpneo_admin_settings_submit_btn');
  244.         ?>
  245.  
  246.         <a href="javascript:;" class="button wpneo-crowdfunding-reset-btn"> <i class="dashicons dashicons-image-rotate"></i> <?php _e('Reset Settings', 'wp-crowdfunding'); ?></a>
  247.     </form>
  248.     <?php
  249. }
  250.  
  251. /**
  252.  * Add settings option
  253.  */
  254. if (wpneo_post('wpneo_admin_settings_submit_btn') && wp_verify_nonce( sanitize_text_field(wpneo_post('wpneo_settings_page_nonce_field')), 'wpneo_settings_page_action' ) ){
  255.  
  256.     $wpneo_crowdfunding_admin_tab = sanitize_text_field(wpneo_post('wpneo_crowdfunding_admin_tab'));
  257.     if ( ! empty($wpneo_crowdfunding_admin_tab)) {
  258.  
  259.         /**
  260.          * General Settings
  261.          */
  262.  
  263.         if (sanitize_text_field(wpneo_post('wpneo_crowdfunding_admin_tab')) == 'tab_general'){
  264.  
  265.             $vendor_type = sanitize_text_field(wpneo_post('vendor_type'));
  266.             wpneo_crowdfunding_update_option_text('vendor_type', $vendor_type);
  267.  
  268.             $wpneo_default_campaign_status = sanitize_text_field(wpneo_post('wpneo_default_campaign_status'));
  269.             wpneo_crowdfunding_update_option_text('wpneo_default_campaign_status', $wpneo_default_campaign_status);
  270.  
  271.             $wpneo_show_min_price = sanitize_text_field(wpneo_post('wpneo_show_min_price'));
  272.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_min_price', $wpneo_show_min_price);
  273.  
  274.             $wpneo_show_max_price = sanitize_text_field(wpneo_post('wpneo_show_max_price'));
  275.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_max_price', $wpneo_show_max_price);
  276.  
  277.             $wpneo_show_recommended_price = sanitize_text_field(wpneo_post('wpneo_show_recommended_price'));
  278.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_recommended_price', $wpneo_show_recommended_price);
  279.  
  280.             $wpneo_show_target_goal = sanitize_text_field(wpneo_post('wpneo_show_target_goal'));
  281.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_target_goal', $wpneo_show_target_goal);
  282.  
  283.             $wpneo_show_target_date = sanitize_text_field(wpneo_post('wpneo_show_target_date'));
  284.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_target_date', $wpneo_show_target_date);
  285.  
  286.             $wpneo_show_target_goal_and_date = sanitize_text_field(wpneo_post('wpneo_show_target_goal_and_date'));
  287.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_target_goal_and_date', $wpneo_show_target_goal_and_date);
  288.  
  289.             $wpneo_show_campaign_never_end = sanitize_text_field(wpneo_post('wpneo_show_campaign_never_end'));
  290.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_campaign_never_end', $wpneo_show_campaign_never_end);
  291.  
  292.             $wpneo_enable_paypal_per_campaign_email = sanitize_text_field(wpneo_post('wpneo_enable_paypal_per_campaign_email'));
  293.             wpneo_crowdfunding_update_option_checkbox('wpneo_enable_paypal_per_campaign_email', $wpneo_enable_paypal_per_campaign_email);
  294.  
  295.             $wpneo_user_role_selector = wpneo_post('wpneo_user_role_selector');
  296.             update_option( 'wpneo_user_role_selector', $wpneo_user_role_selector );
  297.             function wpneo_crowdfunding_add_theme_caps() {
  298.                 $role_list = maybe_unserialize(get_option( 'wpneo_user_role_selector' ));
  299.  
  300.                 // Init Setup Action
  301.                 //$roles  = maybe_unserialize(get_option( 'wp_user_roles' ));
  302.                 $roles  = get_editable_roles();
  303.                 foreach( $roles as $key=>$role ){
  304.                     if( isset( $role['capabilities']['campaign_form_submit'] ) ){
  305.                         $role = get_role( $key );
  306.                         $role->remove_cap( 'campaign_form_submit' );
  307.                     }
  308.                 }
  309.  
  310.                 if( is_array( $role_list ) ){
  311.                     if( !empty( $role_list ) ){
  312.                         foreach( $role_list as $val ){
  313.                             $role = get_role( $val );
  314.                             $role->add_cap( 'campaign_form_submit' );
  315.                             $role->add_cap( 'upload_files' );
  316.                         }
  317.                     }
  318.                 }
  319.             }
  320.             add_action( 'admin_init', 'wpneo_crowdfunding_add_theme_caps');
  321.  
  322.             $wpneo_form_page_id = intval(wpneo_post('wpneo_form_page_id'));
  323.  
  324.             if (!empty($wpneo_form_page_id)) {
  325.                 global $wpdb;
  326.                 $page_id = $wpneo_form_page_id;
  327.                 update_option( 'wpneo_form_page_id', $page_id );
  328.  
  329.                 //Update That Page with new crowdFunding [wpneo_crowdfunding_form]
  330.                 $previous_content = str_replace('[wpneo_crowdfunding_form]', '', get_post_field('post_content', $page_id));
  331.                 $new_content = $previous_content . '[wpneo_crowdfunding_form]';
  332.                 //Update Post
  333.                 $wpdb->update($wpdb->posts, array('post_content' => $new_content), array('ID'=> $page_id));
  334.             }
  335.  
  336.             $wpneo_crowdfunding_dashboard_page_id = intval(wpneo_post('wpneo_crowdfunding_dashboard_page_id'));
  337.             if (!empty($wpneo_crowdfunding_dashboard_page_id)) {
  338.                 $page_id = $wpneo_crowdfunding_dashboard_page_id;
  339.                 update_option('wpneo_crowdfunding_dashboard_page_id', $page_id);
  340.  
  341.                 //Update That Page with new crowdFunding [wpneo_crowdfunding_dashboard]
  342.                 $previous_content = str_replace('[wpneo_crowdfunding_dashboard]', '', get_post_field('post_content', $page_id));
  343.                 $new_content = $previous_content . '[wpneo_crowdfunding_dashboard]';
  344.                 //Update Post
  345.                 $wpdb->update($wpdb->posts, array('post_content' => $new_content), array('ID'=> $page_id));
  346.             }
  347.  
  348.             $wpcf_user_reg_success_redirect_uri = sanitize_text_field(wpneo_post('wpcf_user_reg_success_redirect_uri'));
  349.             update_option('wpcf_user_reg_success_redirect_uri', $wpcf_user_reg_success_redirect_uri);
  350.  
  351.         }
  352.  
  353.         /**
  354.          * Listing Page Settings
  355.          */
  356.         if (sanitize_text_field(wpneo_post('wpneo_crowdfunding_admin_tab')) == 'tab_listing_page'){
  357.             $number_of_collumn_in_row = intval(wpneo_post('number_of_collumn_in_row'));
  358.             wpneo_crowdfunding_update_option_text('number_of_collumn_in_row', $number_of_collumn_in_row);
  359.  
  360.             $number_of_words_show_in_listing_description = intval(wpneo_post('number_of_words_show_in_listing_description'));
  361.             wpneo_crowdfunding_update_option_text('number_of_words_show_in_listing_description', $number_of_words_show_in_listing_description);
  362.  
  363.             $wpneo_show_rating = sanitize_text_field(wpneo_post('wpneo_show_rating'));
  364.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_rating', $wpneo_show_rating);
  365.         }
  366.  
  367.         /**
  368.          * Single Page Settings
  369.          */
  370.         if (sanitize_text_field(wpneo_post('wpneo_crowdfunding_admin_tab')) == 'tab_single_page'){
  371.             $wpneo_single_page_reward_design = intval(wpneo_post('wpneo_single_page_reward_design'));
  372.             wpneo_crowdfunding_update_option_text('wpneo_single_page_reward_design', $wpneo_single_page_reward_design);
  373.  
  374.             $reward_fixed_price = sanitize_text_field(wpneo_post('wpneo_reward_fixed_price'));
  375.             wpneo_crowdfunding_update_option_checkbox('wpneo_reward_fixed_price', $reward_fixed_price);
  376.         }
  377.  
  378.  
  379.         /**
  380.          * WooCommerce Settings
  381.          */
  382.         if (sanitize_text_field(wpneo_post('wpneo_crowdfunding_admin_tab')) == 'tab_woocommerce') {
  383.             $hide_cf_campaign_from_shop_page = sanitize_text_field(wpneo_post('hide_cf_campaign_from_shop_page'));
  384.             wpneo_crowdfunding_update_option_checkbox('hide_cf_campaign_from_shop_page', $hide_cf_campaign_from_shop_page);
  385.  
  386.             $wpneo_single_page_id = sanitize_text_field(wpneo_post('wpneo_single_page_id'));
  387.             wpneo_crowdfunding_update_option_checkbox('wpneo_single_page_id', $wpneo_single_page_id);
  388.  
  389.             $hide_cf_address_from_checkout = sanitize_text_field(wpneo_post('hide_cf_address_from_checkout'));
  390.             wpneo_crowdfunding_update_option_checkbox('hide_cf_address_from_checkout', $hide_cf_address_from_checkout);
  391.  
  392.             $wpneo_listing_page_id = intval(sanitize_text_field(wpneo_post('wpneo_listing_page_id')));
  393.             wpneo_crowdfunding_update_option_text('wpneo_listing_page_id', $wpneo_listing_page_id);
  394.  
  395.             $wpneo_form_page_id = intval(sanitize_text_field(wpneo_post('wpneo_form_page_id')));
  396.             wpneo_crowdfunding_update_option_text('wpneo_form_page_id', $wpneo_form_page_id);
  397.  
  398.             $wpneo_registration_page_id = intval(sanitize_text_field(wpneo_post('wpneo_registration_page_id')));
  399.             wpneo_crowdfunding_update_option_text('wpneo_registration_page_id', $wpneo_registration_page_id);
  400.  
  401.             $seperate_crowdfunding_categories = sanitize_text_field(wpneo_post('seperate_crowdfunding_categories'));
  402.             wpneo_crowdfunding_update_option_checkbox('seperate_crowdfunding_categories', $seperate_crowdfunding_categories);
  403.  
  404.             $wpneo_cf_selected_theme = sanitize_text_field(wpneo_post('wpneo_cf_selected_theme'));
  405.             wpneo_crowdfunding_update_option_text('wpneo_cf_selected_theme', $wpneo_cf_selected_theme);
  406.  
  407.             $wpneo_requirement_title = sanitize_text_field(wpneo_post('wpneo_requirement_title'));
  408.             wpneo_crowdfunding_update_option_text('wpneo_requirement_title', $wpneo_requirement_title);
  409.  
  410.             $wpneo_requirement_text = sanitize_text_field(wpneo_post('wpneo_requirement_text'));
  411.             wpneo_crowdfunding_update_option_text('wpneo_requirement_text', $wpneo_requirement_text);
  412.  
  413.             $wpneo_requirement_agree_title = sanitize_text_field(wpneo_post('wpneo_requirement_agree_title'));
  414.             wpneo_crowdfunding_update_option_text('wpneo_requirement_agree_title', $wpneo_requirement_agree_title);
  415.  
  416.             $wpneo_crowdfunding_add_to_cart_redirect = sanitize_text_field(wpneo_post('wpneo_crowdfunding_add_to_cart_redirect'));
  417.             wpneo_crowdfunding_update_option_text('wpneo_crowdfunding_add_to_cart_redirect', $wpneo_crowdfunding_add_to_cart_redirect);
  418.  
  419.             $number_of_collumn_in_row = intval(wpneo_post('number_of_collumn_in_row'));
  420.             wpneo_crowdfunding_update_option_text('number_of_collumn_in_row', $number_of_collumn_in_row);
  421.  
  422.             $number_of_words_show_in_listing_description = intval(wpneo_post('number_of_words_show_in_listing_description'));
  423.             wpneo_crowdfunding_update_option_text('number_of_words_show_in_listing_description', $number_of_words_show_in_listing_description);
  424.  
  425.             $wpneo_show_rating = sanitize_text_field(wpneo_post('wpneo_show_rating'));
  426.             wpneo_crowdfunding_update_option_checkbox('wpneo_show_rating', $wpneo_show_rating);
  427.  
  428.             //Load single campaign to WooCommerce or not
  429.             $wpneo_single_page_template = sanitize_text_field(wpneo_post('wpneo_single_page_template'));
  430.             wpneo_crowdfunding_update_option_checkbox('wpneo_single_page_template', $wpneo_single_page_template);
  431.  
  432.             $wpneo_single_page_reward_design = intval(wpneo_post('wpneo_single_page_reward_design'));
  433.             wpneo_crowdfunding_update_option_text('wpneo_single_page_reward_design', $wpneo_single_page_reward_design);
  434.  
  435.             $reward_fixed_price = sanitize_text_field(wpneo_post('wpneo_reward_fixed_price'));
  436.             wpneo_crowdfunding_update_option_checkbox('wpneo_reward_fixed_price', $reward_fixed_price);
  437.  
  438.             $wpcf_enable_tax = sanitize_text_field(wpneo_post('wpcf_enable_tax'));
  439.             wpneo_crowdfunding_update_option_checkbox('wpcf_enable_tax', $wpcf_enable_tax);
  440.         }
  441.  
  442.         /**
  443.          * Style Settings
  444.          */
  445.         if ( sanitize_text_field(wpneo_post('wpneo_crowdfunding_admin_tab')) == 'tab_style' ){
  446.  
  447.             $wpneo_enable_color_styling = sanitize_text_field(wpneo_post('wpneo_enable_color_styling'));
  448.             wpneo_crowdfunding_update_option_checkbox('wpneo_enable_color_styling', $wpneo_enable_color_styling);
  449.  
  450.             $wpneo_color_scheme = sanitize_text_field(wpneo_post('wpneo_color_scheme'));
  451.             wpneo_crowdfunding_update_option_text('wpneo_color_scheme', $wpneo_color_scheme);
  452.  
  453.             $wpneo_button_bg_color = sanitize_text_field(wpneo_post('wpneo_button_bg_color'));
  454.             wpneo_crowdfunding_update_option_text('wpneo_button_bg_color', $wpneo_button_bg_color);
  455.  
  456.             $wpneo_button_bg_hover_color = sanitize_text_field(wpneo_post('wpneo_button_bg_hover_color'));
  457.             wpneo_crowdfunding_update_option_text('wpneo_button_bg_hover_color', $wpneo_button_bg_hover_color);
  458.  
  459.             $wpneo_button_text_color = sanitize_text_field(wpneo_post('wpneo_button_text_color'));
  460.             wpneo_crowdfunding_update_option_text('wpneo_button_text_color', $wpneo_button_text_color);
  461.  
  462.             $wpneo_button_text_hover_color = sanitize_text_field(wpneo_post('wpneo_button_text_hover_color'));
  463.             wpneo_crowdfunding_update_option_text('wpneo_button_text_hover_color', $wpneo_button_text_hover_color);
  464.  
  465.             $wpneo_custom_css = wpneo_post( 'wpneo_custom_css' );
  466.             wpneo_crowdfunding_update_option_text( 'wpneo_custom_css', $wpneo_custom_css );
  467.         }
  468.     }
  469. }
  470.  
  471.  
  472. function neo_crowdfunding_go_premium(){
  473.     $html = '';
  474.     $html .= '<div class="wpneo-premium">';
  475.     $html .= '<h2><span class="wpneo-highlight">WP Crowdfunding</span> <br>Take your crowdfunding <br>site to next level!</h2>';
  476.     $html .= '<iframe width="560" height="315" src="https://www.youtube.com/embed/jHJBV2MbgBw" frameborder="0" allowfullscreen></iframe>';
  477.     $html .= '<p>Try before you buy, here is the try <a href="http://try.themeum.com/plugins/wp-crowdfunding/" target="_blank">demo</a>. WP Crowdfunding premium feature list.</p>';
  478.     $html .= '<ul>';
  479.     $html .= '<li class="dashicons-before dashicons-yes"><span>Unlimited Rewards</span> - You can add unlimited rewards in campaigns.</li>';
  480.     $html .= '<li class="dashicons-before dashicons-yes"><span>PayPal Adaptive Payment</span> - PayPal Split Payment (chained and parallel) for crowdfunding campaigns.</li>';
  481.     $html .= '<li class="dashicons-before dashicons-yes"><span>Native Wallet</span> - Crowdfunding Enterprise comes with the native wallet system.</li>';
  482.     $html .= '<li class="dashicons-before dashicons-yes"><span>Authorize.net (AIM) Support</span> - Crowdfunding Enterprise comes with the Authorize.net addons.</li>';
  483.     $html .= '<li class="dashicons-before dashicons-yes"><span>Stripe Connect</span> -  Stripe Split Payment for crowdfunding campaigns.</li>';
  484.     $html .= '<li class="dashicons-before dashicons-yes"><span>Google reCAPTCHA</span> - Helps you prevent spamming in user campaign submission, registration and login.</li>';
  485.     $html .= '<li class="dashicons-before dashicons-yes"><span>Email Notifications</span> - Send emails on campaign submission, campaign approval, new backing and user registration.</li>';
  486.     $html .= '<li class="dashicons-before dashicons-yes"><span>Analytical Reports</span> - Generate crowdfunding sales report and top campaign lists.</li>';
  487.     $html .= '<li class="dashicons-before dashicons-yes"><span>Social Share</span> - Share the campaigns on popular social media.</li>';
  488.     $html .= '<li class="dashicons-before dashicons-yes"><span>Native Wallet System</span> - An alternate way of PayPal And Stripe Connect to spilt raised amount between campaign creator and website admin .</li>';
  489.     $html .= '<li class="dashicons-before dashicons-yes"><span>1 Year Support</span> - Dedicated support for any issue.</li>';
  490.     $html .= '<li class="dashicons-before dashicons-yes"><span>1 Year Update</span> - You can get immidiate fixes and regular updates.</li>';
  491.     $html .= '<li class="dashicons-before dashicons-yes"><span>1 Free Theme</span> - You will get a free WordPress theme, check the <a href="http://demo.themeum.com/wordpress/crowdfunding-theme/" target="_blank">demo theme</a>.</li>';
  492.     $html .= '</ul>';
  493.  
  494.  
  495.  
  496.     $html .= '<a target="_blank" href="https://www.themeum.com/product/wp-crowdfunding-plugin/" class="wpneo-buynow">Buy WP Crowdfunding Premium Now >></a>';
  497.     $html .= '</div>';
  498.  
  499.     echo $html;
  500. }
  501.  
  502. /**
  503.  * Neo Crowdfunding Custom Styling Option
  504.  */
  505. add_action( 'wp_head','wpneo_custom_css' );
  506. function wpneo_custom_css(){
  507.  
  508.     if( 'true' == get_option('wpneo_enable_color_styling') ){
  509.         $color_scheme       = get_option( 'wpneo_color_scheme' );
  510.         $button_bg          = get_option( 'wpneo_button_bg_color' );
  511.         $button_bg_hover    = get_option( 'wpneo_button_bg_hover_color' );
  512.         $button_text_color  = get_option( 'wpneo_button_text_color' );
  513.         $text_hover_color   = get_option( 'wpneo_button_text_hover_color' );
  514.         $custom_css         = get_option( 'wpneo_custom_css' );
  515.  
  516.         $style = '';
  517.  
  518.         if( $button_bg ){
  519.             $style .= '.wpneo_donate_button,
  520.                        #wpneo-tab-reviews .submit,
  521.                        .wpneo-edit-btn,
  522.                        .wpneo-image-upload.float-right,
  523.                        .wpneo-image-upload-btn,
  524.                        .wpneo-save-btn,
  525.                        #wpneo_active_edit_form,
  526.                        .removeCampaignRewards,
  527.                        #addreward,
  528.                        .btn-style1,
  529.                        #addcampaignupdate,
  530.                        .wpneo-profile-button,
  531.                        .dashboard-btn-link,
  532.                        .wpneo_login_form_div #wp-submit,
  533.                        .wpneo-submit-campaign,
  534.                        input[type="button"].wpneo-image-upload,
  535.                        #addreward,input[type="submit"].wpneo-submit-campaign,
  536.                        .dashboard-btn-link,.label-primary,
  537.                        .btn-style1,#wpneo-tab-reviews .submit,.dashboard-head-date input[type="submit"],
  538.                        .wp-crowd-btn-primary, .wpneo_withdraw_button,.wpneo-dashboard-head-left ul li.active,
  539.                        .wpneo-pagination ul li a:hover, .wpneo-pagination ul li span.current{ background-color:'.$button_bg.'; color:'.$button_text_color.'; }';
  540.  
  541.             $style .= '.wpneo_donate_button:hover,
  542.                        #wpneo-tab-reviews .submit:hover,
  543.                        .wpneo-edit-btn:hover,
  544.                        .wpneo-image-upload.float-right:hover,
  545.                        .wpneo-image-upload-btn:hover,
  546.                        .wpneo-save-btn:hover,
  547.                        .removeCampaignRewards:hover,
  548.                        #addreward:hover,
  549.                        .removecampaignupdate:hover,
  550.                        .btn-style1:hover,
  551.                        #addcampaignupdate:hover,
  552.                        #wpneo_active_edit_form:hover,
  553.                        .removecampaignupdate:hover,
  554.                        .wpneo-profile-button:hover,
  555.                        .dashboard-btn-link:hover,
  556.                        .wpneo_login_form_div #wp-submit:hover,
  557.                        .wpneo-submit-campaign:hover,
  558.                        .wpneo_donate_button:hover,.dashboard-head-date input[type="submit"]:hover,
  559.                        .wp-crowd-btn-primary:hover,
  560.                        .wpneo_withdraw_button:hover{ background-color:'.$button_bg_hover.'; color:'.$text_hover_color.'; }';
  561.         }
  562.  
  563.         if( $color_scheme ){
  564.             $style .=  '#neo-progressbar > div,
  565.                        ul.wpneo-crowdfunding-update li:hover span.round-circle,
  566.                        .wpneo-links li a:hover, .wpneo-links li.active a,#neo-progressbar > div {
  567.                            background-color: '.$color_scheme.';
  568.                        }
  569.                        .wpneo-dashboard-summery ul li.active {
  570.                            background: '.$color_scheme.';
  571.                        }
  572.                        .wpneo-tabs-menu li.wpneo-current {
  573.                            border-bottom: 3px solid '.$color_scheme.';
  574.                        }
  575.                        .wpneo-pagination ul li a:hover,
  576.                        .wpneo-pagination ul li span.current {
  577.                            border: 2px solid '.$color_scheme.';
  578.                        }
  579.                        .wpneo-dashboard-summery ul li.active:after {
  580.                            border-color: '.$color_scheme.' rgba(0, 128, 0, 0) rgba(255, 255, 0, 0) rgba(0, 0, 0, 0);
  581.                        }
  582.                        .wpneo-fields input[type="email"]:focus,
  583.                        .wpneo-fields input[type="text"]:focus,
  584.                        .wpneo-fields select:focus,
  585.                        .wpneo-fields textarea {
  586.                            border-color: '.$color_scheme.';
  587.                        }
  588.                        .wpneo-link-style1,
  589.                        ul.wpneo-crowdfunding-update li .wpneo-crowdfunding-update-title,
  590.                        .wpneo-fields-action span a:hover,.wpneo-name > p,
  591.                        .wpneo-listings-dashboard .wpneo-listing-content h4 a,
  592.                        .wpneo-listings-dashboard .wpneo-listing-content .wpneo-author a,
  593.                        .wpcf-order-view,#wpneo_crowdfunding_modal_message td a,
  594.                        .dashboard-price-number,.wpcrowd-listing-content .wpcrowd-admin-title h3 a,
  595.                        .campaign-listing-page .stripe-table a,.stripe-table  a.label-default:hover,
  596.                        a.wpneo-fund-modal-btn.wpneo-link-style1,.wpneo-tabs-menu li.wpneo-current a,
  597.                        .wpneo-links div a:hover, .wpneo-links div.active a{
  598.                            color: '.$color_scheme.';
  599.                        }
  600.                        .wpneo-links div a:hover .wpcrowd-arrow-down, .wpneo-links div.active a .wpcrowd-arrow-down {
  601.                            border: solid '.$color_scheme.';
  602.                            border-width: 0 2px 2px 0;
  603.                        }
  604.                        .wpneo-listings-dashboard .wpneo-listing-content h4 a:hover,
  605.                        .wpneo-listings-dashboard .wpneo-listing-content .wpneo-author a:hover,
  606.                        #wpneo_crowdfunding_modal_message td a:hover{
  607.                            color: rgba('.$color_scheme.','.$color_scheme.','.$color_scheme.',0.95);
  608.                        }';
  609.  
  610.             list($r, $g, $b) = sscanf( $color_scheme, "#%02x%02x%02x" );
  611.             $style .=  '.tab-rewards-wrapper .overlay {
  612.                            background: rgba('.$r.','.$g.','.$b.',.95);
  613.                        }';
  614.         }
  615.  
  616.         if( $custom_css ){ $style .= $custom_css; }
  617.  
  618.         $output = '<style type="text/css"> '.$style.' </style>';
  619.         echo $output;
  620.     }
  621. }
  622.  
  623.  
  624.  
  625. /**
  626.  * Neo Crowdfunding option page menu
  627.  */
  628. function neo_crowdfunding_register_menu_page(){
  629.  
  630.     add_menu_page( 'Crowdfunding','Crowdfunding','manage_options','wpneo-crowdfunding','','dashicons-admin-multisite', null );
  631.     add_submenu_page(
  632.         'wpneo-crowdfunding',
  633.         __('Settings', 'wp-crowdfunding'),
  634.         __('Settings', 'wp-crowdfunding'),
  635.         'manage_options',
  636.         'wpneo-crowdfunding',
  637.         'neo_crowdfunding_menu_page'
  638.     );
  639.  
  640.     $adaptive = WPNEO_CROWDFUNDING_DIR_PATH.'addons/paypal-adaptive/classes/class-wpneo-adaptive-payment-initiate.php';
  641.     if (WPNEO_CROWDFUNDING_TYPE == 'free'){
  642.         add_submenu_page( 'wpneo-crowdfunding', __( 'Go Premium', 'wp-crowdfunding' ), __( 'Go Premium <span class="dashicons dashicons-star-filled"></span>', 'wp-crowdfunding' ), 'manage_options', 'wp-crowdfunding', 'neo_crowdfunding_go_premium' );
  643.     }
  644. }
  645. add_action( 'admin_menu', 'neo_crowdfunding_register_menu_page' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement