Plugin Directory

source: lead-form-builder/trunk/inc/lf-install.php

Last change on this file was 3183742, checked in by themehunk, 5 months ago

1.9.7

  • Fix:Vulnerability issue fixed.
File size: 6.4 KB
Line 
1<?php
2if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3/*
4 * Include assets
5 */
6function lfb_admin_assets($hook) {
7    $pageSearch = array('admin_page_add-new-form','admin_page_all-form-leads','themehunk_page_wplf-plugin-menu','admin_page_pro-form-leads');
8    if(in_array($hook, $pageSearch)){
9        wp_enqueue_style('wpth_fa_css', LFB_PLUGIN_URL . 'font-awesome/css/font-awesome.css');
10        wp_enqueue_style('lfb-option-css', LFB_PLUGIN_URL . 'css/option-style.css');
11        wp_enqueue_style('sweet-dropdown.min', LFB_PLUGIN_URL . 'css/jquery.sweet-dropdown.min.css');
12        wp_enqueue_style('wpth_b_css', LFB_PLUGIN_URL . 'css/b-style.css');
13        wp_enqueue_script('lfb_modernizr_js', LFB_PLUGIN_URL . 'js/modernizr.js', '', LFB_VER, true);
14        wp_enqueue_script('jquery-ui-datepicker');
15        wp_enqueue_script("jquery-ui-sortable");
16        wp_enqueue_script("jquery-ui-draggable");
17        wp_enqueue_script("jquery-ui-droppable"); 
18        wp_enqueue_script("jquery-ui-accordion");
19        wp_enqueue_style( 'jquery-ui' ); 
20        wp_enqueue_script('lfb_upload', LFB_PLUGIN_URL . 'js/upload.js', '', LFB_VER, true);
21        wp_enqueue_script('sweet-dropdown.min', LFB_PLUGIN_URL . 'js/jquery.sweet-dropdown.min.js', '', LFB_VER, true);
22        wp_enqueue_script('lfb_b_js', LFB_PLUGIN_URL . 'js/b-script.js', array('jquery'), LFB_VER, true);
23        wp_localize_script('lfb_b_js', 'backendajax', array('ajaxurl' => admin_url('admin-ajax.php')));
24    }
25
26}
27add_action('admin_enqueue_scripts', 'lfb_admin_assets');
28
29function lfb_wp_assets() {
30    wp_enqueue_style('lfb_f_css', LFB_PLUGIN_URL . 'css/f-style.css');
31    wp_enqueue_script('jquery-ui-datepicker');       
32    wp_enqueue_script('lfb_f_js', LFB_PLUGIN_URL . 'js/f-script.js', array('jquery'), LFB_VER, true);
33    wp_localize_script('lfb_f_js', 'frontendajax', array('ajaxurl' => admin_url('admin-ajax.php'),'_wpnonce' => wp_create_nonce( 'lfb_front_nonce' )));
34    wp_enqueue_style('font-awesome', LFB_PLUGIN_URL . 'font-awesome/css/font-awesome.css');
35}
36add_action('wp_enqueue_scripts', 'lfb_wp_assets', 15);
37/*
38 * Register custom menu pages.
39 */
40function lfb_register_my_custom_menu_page() {
41
42$user = get_userdata( get_current_user_id() );
43// Get all the user roles as an array.
44$user_roles = $user->roles;
45add_submenu_page( 'themehunk-plugins', __('Lead Form Builder', 'wppb'), __('Lead Form Builder', 'wppb'), 'manage_options', 'wplf-plugin-menu','lfb_lead_form_page');
46    add_submenu_page(false, __('Add Forms', 'lead-form-builder'), __('Add Forms', 'lead-form-builder'), 'manage_options', 'add-new-form', 'lfb_add_contact_forms');
47    if( in_array( 'administrator', $user_roles, true )) {
48    add_submenu_page(false, __('View Leads', 'lead-form-builder'), __('View Leads', 'lead-form-builder'), 'manage_options', 'all-form-leads', 'lfb_all_forms_lead');
49    }
50    add_submenu_page(false, __('Premium Version', 'th-lead-form'), __('Premium Version', 'th-lead-form'), 'manage_options', 'pro-form-leads', 'lfb_pro_feature');
51
52}
53add_action('admin_menu', 'lfb_register_my_custom_menu_page');
54
55function lfb_lead_form_page() {
56    if (isset($_GET['action']) && isset($_GET['formid'])) {
57        $form_action = sanitize_text_field($_GET['action']);
58        $this_form_id = intval($_GET['formid']);
59        $nonce = isset($_REQUEST['_wpnonce'])?$_REQUEST['_wpnonce']:false;
60
61
62        if ($form_action == 'delete' && wp_verify_nonce($nonce, '_nonce_verify')) {
63            $page_id =1;
64            if (isset($_GET['page_id'])) {
65            $page_id = intval($_GET['page_id']);
66            }
67            $th_edit_del_form = new LFB_EDIT_DEL_FORM();
68            $th_edit_del_form->lfb_delete_form_content($form_action, $this_form_id,$page_id);
69        }
70        if ($form_action == 'show' && isset($_GET['formid'])) {
71                $fid = intval($_GET['formid']); 
72                echo "<div class='lfb-show'><h1>". esc_html('Lead Form Preview Page')."</h1>";
73            echo do_shortcode('[lead-form form-id="'.$fid.'" title=Contact Us]');
74
75            echo "<div>";
76        }
77        if ($form_action == 'today_leads') {
78            $th_show_today_leads = new LFB_Show_Leads();
79            $th_show_today_leads->lfb_show_form_leads_datewise($this_form_id,"today_leads");
80        }
81        if ($form_action == 'total_leads') {
82            $th_show_all_leads = new LFB_Show_Leads();
83            $th_show_all_leads->lfb_show_form_leads_datewise($this_form_id,"total_leads");
84        }
85    } else {
86        $th_show_forms = new LFB_SHOW_FORMS();
87        $page_id =1;
88        if (isset($_GET['page_id'])) {
89        $page_id = intval($_GET['page_id']);
90        }
91        $th_show_forms->lfb_show_all_forms($page_id);
92    }
93}
94
95// extra slas remove
96function lfb_array_stripslash($theArray){
97   foreach ( $theArray as &$v ) if ( is_array($v) ) $v = lfb_array_stripslash($v); else $v = stripslashes($v);
98   return $theArray;
99}
100
101// form builder update nad delete function
102function lfb_add_contact_forms() {
103    if (isset($_POST['update_form']) && wp_verify_nonce($_REQUEST['_wpnonce'],'_nonce_verify') ) {
104    $data_form =isset($_POST['lfb_form'])?$_POST['lfb_form']:'';
105    $update_form_id = intval($_POST['update_form_id']);
106    $title = sanitize_text_field($_POST['post_title']);
107    unset($_POST['_wpnonce']);
108    unset($_POST['post_title']);
109    unset($_POST['update_form']);
110    unset($_POST['update_form_id']);
111    global $wpdb;
112    $table_name = LFB_FORM_FIELD_TBL;
113    $update_leads = $wpdb->update( 
114    $table_name,
115    array( 
116        'form_title' => $title,
117      'form_data' => maybe_serialize(lfb_create_form_sanitize($data_form))
118    ), 
119    array( 'id' => $update_form_id ));
120    $rd_url = esc_url(admin_url().'admin.php?page=add-new-form&action=edit&redirect=update&formid='.$update_form_id);
121    $complete_url = wp_nonce_url($rd_url);
122  }
123
124if (isset($_GET['action']) && isset($_GET['formid'])) {
125        $form_action = sanitize_text_field($_GET['action']);
126        $this_form_id = intval($_GET['formid']);
127        if ($form_action == 'edit') {
128            $th_edit_del_form = new LFB_EDIT_DEL_FORM();
129            $th_edit_del_form->lfb_edit_form_content($form_action, $this_form_id);
130        }
131    } else {
132        $lf_add_new_form = new LFB_AddNewForm();
133        $lf_add_new_form->lfb_add_new_form();
134    }
135}
136
137function lfb_all_forms_lead() {
138    $th_show_forms = new LFB_Show_Leads();
139    $th_show_forms->lfb_show_form_leads();
140}
141
142
143
144function lfb_pro_feature(){
145
146include_once( plugin_dir_path(__FILE__) . 'options/option.php' );
147
148}
Note: See TracBrowser for help on using the repository browser.