function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Email Input', 'nm-personalizedproduct');
     $this->desc = __('regular email input', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Price Matrix', 'nm-personalizedproduct');
     $this->desc = __('Price/Quantity', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Section', 'nm-personalizedproduct');
     $this->desc = __('Form section', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Radio Input', 'nm-personalizedproduct');
     $this->desc = __('regular radio input', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = false;
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('File Input', 'nm-personalizedproduct');
     $this->desc = __('regular file input', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
     $this->input_scripts = array('shipped' => array(''), 'custom' => array(array('script_name' => 'plupload_script', 'script_source' => '/js/plupload-2.1.2/js/plupload.full.min.js', 'localized' => false, 'type' => 'js', 'depends' => array('jquery'), 'in_footer' => '')));
     add_action('wp_enqueue_scripts', array($this, 'load_input_scripts'));
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Date Input', 'nm-personalizedproduct');
     $this->desc = __('regular date input', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
     $this->input_scripts = array('shipped' => array('jquery-ui-datepicker'), 'custom' => NULL);
     add_action('wp_enqueue_scripts', array($this, 'load_input_scripts'));
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Color picker', 'nm-personalizedproduct');
     $this->desc = __('Color pallete input', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
     $this->input_scripts = array('shipped' => array(''), 'custom' => array(array('script_name' => 'wp_iris_script', 'script_source' => '/js/color/Iris/dist/iris.min.js', 'localized' => false, 'type' => 'js', 'depends' => array('jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-slider'), 'in_footer' => '')));
     add_action('wp_enqueue_scripts', array($this, 'load_input_scripts'));
 }
 function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
     $this->title = __('Instagram import', 'nm-personalizedproduct');
     $this->desc = __('Import photo from Instagram, NOTE: this feature is paid but it is placed here for testing', 'nm-personalizedproduct');
     $this->settings = self::get_settings();
     $this->ispro = true;
     $this->access_token_url = 'https://api.instagram.com/oauth/access_token';
     $this->grant_type = 'authorization_code';
     $this->response_type = 'code';
 }
 function __construct()
 {
     // setting plugin meta saved in config.php
     $this->plugin_meta = get_plugin_meta_wooproduct();
     // getting saved settings
     $this->plugin_settings = get_option($this->plugin_meta['shortname'] . '_settings');
     // populating $inputs with NM_Inputs object
     $this->inputs = self::get_all_inputs();
     $this->menu_pages = array(array('page_title' => __('PersonalizedWOO', 'nm-personalizedproduct'), 'menu_title' => __('PersonalizedWOO', 'nm-personalizedproduct'), 'cap' => 'manage_options', 'slug' => 'nm-personalizedproduct', 'callback' => 'product_meta', 'parent_slug' => 'options-general.php'));
     /*
      * [2] TODO: Change this for admin related scripts JS scripts and styles to loaded ADMIN
      */
     $this->plugin_scripts_admin = array(array('script_name' => 'scripts-global', 'script_source' => '/js/nm-global.js', 'localized' => false, 'type' => 'js', 'page_slug' => 'nm-personalizedproduct'), array('script_name' => 'scripts-admin', 'script_source' => '/js/admin.js', 'localized' => true, 'type' => 'js', 'page_slug' => array('nm-personalizedproduct'), 'depends' => array('jquery', 'jquery-ui-accordion', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-slider', 'jquery-ui-dialog', 'jquery-ui-tabs')), array('script_name' => 'ui-style', 'script_source' => '/js/ui/css/smoothness/jquery-ui-1.10.3.custom.min.css', 'localized' => false, 'type' => 'style', 'page_slug' => array('nm-personalizedproduct', 'nm-new-form')), array('script_name' => 'thickbox', 'script_source' => 'shipped', 'localized' => false, 'type' => 'style', 'page_slug' => array('nm-new-form')), array('script_name' => 'plugin-css', 'script_source' => '/templates/admin/style.css', 'localized' => false, 'type' => 'style', 'page_slug' => array('nm-personalizedproduct', 'nm-new-form')));
     add_action('admin_menu', array($this, 'add_menu_pages'));
     /**
      * laoding admin scripts only for plugin pages
      * since 27 september, 2014
      * Najeeb's 
      */
     add_action('admin_enqueue_scripts', array($this, 'load_scripts_admin'));
 }
 /**
  * __construct function.
  *
  * @access public
  * @param 
  */
 public function __construct()
 {
     $this->plugin_meta = get_plugin_meta_wooproduct();
 }
 function save_edited_photo()
 {
     $aviary_addon_dir = 'nm-aviary-photo-editing-addon/index.php';
     $file_path = ABSPATH . 'wp-content/plugins/' . $aviary_addon_dir;
     if (!file_exists($file_path)) {
         die('Could not find file ' . $file_path);
     }
     include_once $file_path;
     $aviary = new NM_Aviary();
     // setting plugin meta saved in config.php
     $aviary->plugin_meta = get_plugin_meta_wooproduct();
     $aviary->dir_path = $this->get_file_dir_path();
     $aviary->dir_name = $this->product_files;
     $aviary->posted_data = json_decode(stripslashes($_REQUEST['postdata']));
     $aviary->image_data = file_get_contents($_REQUEST['url']);
     $aviary->image_url = $_REQUEST['url'];
     $aviary->save_file_locally();
     die(0);
 }
function render_input_types($type, $name, $value = '', $options = '')
{
    $plugin_meta = get_plugin_meta_wooproduct();
    $html_input = '';
    // var_dump($value);
    if (!is_array($value)) {
        $value = stripslashes($value);
    }
    switch ($type) {
        case 'text':
            $html_input .= '<input type="text" name="' . $name . '" value="' . esc_html($value) . '">';
            break;
        case 'textarea':
            $html_input .= '<textarea name="' . $name . '">' . esc_html($value) . '</textarea>';
            break;
        case 'select':
            $html_input .= '<select name="' . $name . '">';
            foreach ($options as $key => $val) {
                $selected = $key == $value ? 'selected="selected"' : '';
                $html_input .= '<option value="' . $key . '" ' . $selected . '>' . esc_html($val) . '</option>';
            }
            $html_input .= '</select>';
            break;
        case 'paired':
            if ($value) {
                foreach ($value as $option) {
                    $html_input .= '<div class="data-options" style="border: dashed 1px;">';
                    $html_input .= '<input type="text" name="options[option]" value="' . $option['option'] . '" placeholder="' . __('option', 'nm-personalizedproduct') . '">';
                    $html_input .= '<input type="text" name="options[price]" value="' . $option['price'] . '" placeholder="' . __('price (if any)', 'nm-personalizedproduct') . '">';
                    $html_input .= '<img class="add_option" src="' . $plugin_meta['url'] . '/images/plus.png" title="add rule" alt="add rule" style="cursor:pointer; margin:0 3px;">';
                    $html_input .= '<img class="remove_option" src="' . $plugin_meta['url'] . '/images/minus.png" title="remove rule" alt="remove rule" style="cursor:pointer; margin:0 3px;">';
                    $html_input .= '</div>';
                }
            } else {
                $html_input .= '<div class="data-options" style="border: dashed 1px;">';
                $html_input .= '<input type="text" name="options[option]" placeholder="' . __('option', 'nm-personalizedproduct') . '">';
                $html_input .= '<input type="text" name="options[price]" placeholder="' . __('price (if any)', 'nm-personalizedproduct') . '">';
                $html_input .= '<img class="add_option" src="' . $plugin_meta['url'] . '/images/plus.png" title="add rule" alt="add rule" style="cursor:pointer; margin:0 3px;">';
                $html_input .= '<img class="remove_option" src="' . $plugin_meta['url'] . '/images/minus.png" title="remove rule" alt="remove rule" style="cursor:pointer; margin:0 3px;">';
                $html_input .= '</div>';
            }
            break;
        case 'checkbox':
            if ($options) {
                foreach ($options as $key => $val) {
                    parse_str($value, $saved_data);
                    $checked = '';
                    if (isset($saved_data['editing_tools']) && $saved_data['editing_tools']) {
                        if (in_array($key, $saved_data['editing_tools'])) {
                            $checked = 'checked="checked"';
                        } else {
                            $checked = '';
                        }
                    }
                    // $html_input .= '<option value="' . $key . '" ' . $selected . '>' . $val . '</option>';
                    $html_input .= '<input type="checkbox" value="' . $key . '" name="' . $name . '[]" ' . $checked . '> ' . $val . '<br>';
                }
            } else {
                $checked = isset($value) && $value != '' ? 'checked = "checked"' : '';
                $html_input .= '<input type="checkbox" name="' . $name . '" ' . $checked . '>';
            }
            break;
        case 'html-conditions':
            // nm_personalizedproduct_pa($value);
            $rule_i = 1;
            if ($value) {
                $visibility_show = $value['visibility'] == 'Show' ? 'selected="selected"' : '';
                $visibility_hide = $value['visibility'] == 'Hide' ? 'selected="selected"' : '';
                $html_input = '<select name="condition_visibility">';
                $html_input .= '<option ' . $visibility_show . '>' . __('Show', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option ' . $visibility_hide . '>' . __('Hide', 'nm-personalizedproduct') . '</option>';
                $html_input .= '</select> ';
                $html_input .= __('only if', 'nm-personalizedproduct');
                $bound_all = $value['bound'] == 'All' ? 'selected="selected"' : '';
                $bound_any = $value['bound'] == 'Any' ? 'selected="selected"' : '';
                $html_input .= '<select name="condition_bound">';
                $html_input .= '<option ' . $bound_all . '>' . __('All', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option ' . $bound_any . '>' . __('Any', 'nm-personalizedproduct') . '</option>';
                $html_input .= '</select> ';
                $html_input .= __(' of the following matches', 'nm-personalizedproduct');
                foreach ($value['rules'] as $condition) {
                    // conditional elements
                    $html_input .= '<div class="webcontact-rules" id="rule-box-' . $rule_i . '">';
                    $html_input .= '<br><strong>' . __('Rule # ', 'nm-personalizedproduct') . $rule_i++ . '</strong><br>';
                    $html_input .= '<select name="condition_elements" data-existingvalue="' . $condition['elements'] . '" onblur="load_conditional_values(this)"></select>';
                    // is
                    $operator_is = $condition['operators'] == 'is' ? 'selected="selected"' : '';
                    $operator_not = $condition['operators'] == 'not' ? 'selected="selected"' : '';
                    $operator_greater = $condition['operators'] == 'greater then' ? 'selected="selected"' : '';
                    $operator_less = $condition['operators'] == 'less then' ? 'selected="selected"' : '';
                    $html_input .= '<select name="condition_operators">';
                    $html_input .= '<option ' . $operator_is . '>' . __('is', 'nm-personalizedproduct') . '</option>';
                    $html_input .= '<option ' . $operator_not . '>' . __('not', 'nm-personalizedproduct') . '</option>';
                    $html_input .= '<option ' . $operator_greater . '>' . __('greater then', 'nm-personalizedproduct') . '</option>';
                    $html_input .= '<option ' . $operator_less . '>' . __('less then', 'nm-personalizedproduct') . '</option>';
                    $html_input .= '</select> ';
                    // conditional elements values
                    $html_input .= '<select name="condition_element_values" data-existingvalue="' . $condition['element_values'] . '"></select>';
                    $html_input .= '<img class="add_rule" src="' . $plugin_meta['url'] . '/images/plus.png" title="add rule" alt="add rule" style="cursor:pointer; margin:0 3px;">';
                    $html_input .= '<img class="remove_rule" src="' . $plugin_meta['url'] . '/images/minus.png" title="remove rule" alt="remove rule" style="cursor:pointer; margin:0 3px;">';
                    $html_input .= '</div>';
                }
            } else {
                $html_input = '<select name="condition_visibility">';
                $html_input .= '<option>' . __('Show', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option>' . __('Hide', 'nm-personalizedproduct') . '</option>';
                $html_input .= '</select> ';
                $html_input .= '<select name="condition_bound">';
                $html_input .= '<option>' . __('All', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option>' . __('Any', 'nm-personalizedproduct') . '</option>';
                $html_input .= '</select> ';
                $html_input .= __(' of the following matches', 'nm-personalizedproduct');
                // conditional elements
                $html_input .= '<div class="webcontact-rules" id="rule-box-' . $rule_i . '">';
                $html_input .= '<br><strong>' . __('Rule # ', 'nm-personalizedproduct') . $rule_i++ . '</strong><br>';
                $html_input .= '<select name="condition_elements" data-existingvalue="" onblur="load_conditional_values(this)"></select>';
                // is
                $html_input .= '<select name="condition_operators">';
                $html_input .= '<option>' . __('is', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option>' . __('not', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option>' . __('greater then', 'nm-personalizedproduct') . '</option>';
                $html_input .= '<option>' . __('less then', 'nm-personalizedproduct') . '</option>';
                $html_input .= '</select> ';
                // conditional elements values
                $html_input .= '<select name="condition_element_values" data-existingvalue=""></select>';
                $html_input .= '<img class="add_rule" src="' . $plugin_meta['url'] . '/images/plus.png" title="add rule" alt="add rule" style="cursor:pointer; margin:0 3px;">';
                $html_input .= '<img class="remove_rule" src="' . $plugin_meta['url'] . '/images/minus.png" title="remove rule" alt="remove rule" style="cursor:pointer; margin:0 3px;">';
                $html_input .= '</div>';
            }
            break;
        case 'pre-images':
            //$html_input	.= '<textarea name="pre_upload_images">'.$pre_uploaded_images.'</textarea>';
            $html_input .= '<div class="pre-upload-box">';
            $html_input .= '<input name="pre_upload_image_button" type="button" value="' . __('Select/Upload Image', 'nm-personalizedproduct') . '" />';
            // nm_personalizedproduct_pa($value);
            if ($value) {
                foreach ($value as $pre_uploaded_image) {
                    $image_link = isset($pre_uploaded_image['link']) ? $pre_uploaded_image['link'] : '';
                    $image_id = isset($pre_uploaded_image['id']) ? $pre_uploaded_image['id'] : '';
                    $html_input .= '<table>';
                    $html_input .= '<tr>';
                    $html_input .= '<td><img width="75" src="' . $pre_uploaded_image['link'] . '"></td>';
                    $html_input .= '<input type="hidden" name="pre-upload-link" value="' . $image_link . '">';
                    $html_input .= '<input type="hidden" name="pre-upload-id" value="' . $image_id . '">';
                    $html_input .= '<td><input style="width:100px" type="text" value="' . stripslashes($pre_uploaded_image['title']) . '" name="pre-upload-title"><br>';
                    $html_input .= '<input style="width:100px" type="text" value="' . stripslashes($pre_uploaded_image['price']) . '" name="pre-upload-price"><br>';
                    $html_input .= '<input style="width:100px; color:red" name="pre-upload-delete" type="button" class="button" value="Delete"><br>';
                    $html_input .= '</td></tr>';
                    $html_input .= '</table><br>';
                }
                //$pre_uploaded_images = $value;
            }
            $html_input .= '</div>';
            break;
    }
    return $html_input;
}