コード例 #1
0
 /**
  * Print css stylesheets in the framework/css folder to the admin head
  */
 function add_styles()
 {
     wp_enqueue_style('thickbox');
     $files = avia_backend_load_scripts_by_folder(AVIA_CSS);
     foreach ($files as $index => $file) {
         $file_info = pathinfo($file);
         if (isset($file_info['extension']) && $file_info['extension'] == "css") {
             $filename = basename($file_info['basename'], "." . $file_info['extension']);
             wp_enqueue_style($filename, AVIA_CSS_URL . $file, false, AV_FRAMEWORK_VERSION);
         }
     }
 }
コード例 #2
0
 /**
  * 
  * The select method renders a single select element: it either lists custom values, all wordpress pages or all wordpress categories
  * @param array $element the array holds data like type, value, id, class, description which are necessary to render the whole option-section
  * @return string $output the string returned contains the html code generated within the method
  */
 function select($element)
 {
     $base_url = "";
     $folder_data = "";
     if ($element['subtype'] == 'page') {
         $select = 'Select page';
         $entries = get_pages('title_li=&orderby=name');
     } else {
         if ($element['subtype'] == 'post') {
             $select = 'Select post';
             $entries = get_posts('title_li=&orderby=name&numberposts=9999');
         } else {
             if ($element['subtype'] == 'cat') {
                 $add_taxonomy = "";
                 if (!empty($element['taxonomy'])) {
                     $add_taxonomy = "&taxonomy=" . $element['taxonomy'];
                 }
                 $select = 'Select category';
                 $entries = get_categories('title_li=&orderby=name&hide_empty=0' . $add_taxonomy);
             } else {
                 $select = 'Select...';
                 $entries = $element['subtype'];
                 $add_entries = array();
                 if (isset($element['folder'])) {
                     $add_file_array = avia_backend_load_scripts_by_folder(AVIA_BASE . $element['folder']);
                     $base_url = AVIA_BASE_URL;
                     $folder_data = "data-baseurl='{$base_url}'";
                     if (is_array($add_file_array)) {
                         foreach ($add_file_array as $file) {
                             $skip = false;
                             if (!empty($element['exclude'])) {
                                 foreach ($element['exclude'] as $exclude) {
                                     if (stripos($file, $exclude) !== false) {
                                         $skip = true;
                                     }
                                 }
                             }
                             if (strpos($file, '.') !== 0 && $skip == false) {
                                 $add_entries[$element['folderlabel'] . $file] = "{{AVIA_BASE_URL}}" . $element['folder'] . $file;
                             }
                         }
                         if (isset($element['group'])) {
                             $entries[$element['group']] = $add_entries;
                         } else {
                             $entries = array_merge($entries, $add_entries);
                         }
                     }
                 }
             }
         }
     }
     //check for onchange function
     $onchange = "";
     if (isset($element['onchange'])) {
         $onchange = " data-avia-onchange='" . $element['onchange'] . "' ";
         $element['class'] .= " avia_onchange";
     }
     $multi = $multi_class = "";
     if (isset($element['multiple'])) {
         $multi_class = " avia_multiple_select";
         $multi = 'multiple="multiple" size="' . $element['multiple'] . '"';
         if (!empty($element['std'])) {
             $element['std'] = explode(',', (string) $element['std']);
         }
     }
     $output = '<span class="avia_style_wrap avia_select_style_wrap' . $multi_class . '"><span class="avia_select_unify">';
     $output .= '<select ' . $folder_data . ' ' . $onchange . ' ' . $multi . ' class="' . $element['class'] . '" id="' . $element['id'] . '" name="' . $element['id'] . '"> ';
     if (!isset($element['no_first'])) {
         $output .= '<option value="">' . $select . '</option>  ';
         $fake_val = $select;
     }
     $real_entries = array();
     foreach ($entries as $key => $entry) {
         if (!is_array($entry)) {
             $real_entries[$key] = $entry;
         } else {
             $real_entries['option_group_' . $key] = $key;
             foreach ($entry as $subkey => $subentry) {
                 $real_entries[$subkey] = $subentry;
             }
             $real_entries['close_option_group_' . $key] = "close";
         }
     }
     $entries = $real_entries;
     foreach ($entries as $key => $entry) {
         if ($element['subtype'] == 'page' || $element['subtype'] == 'post') {
             $id = $entry->ID;
             $title = $entry->post_title;
         } else {
             if ($element['subtype'] == 'cat') {
                 if (isset($entry->term_id)) {
                     $id = $entry->term_id;
                     $title = $entry->name;
                 }
             } else {
                 $id = $entry;
                 $title = $key;
             }
         }
         if (!empty($title) || isset($title) && $title === 0) {
             if (!isset($fake_val)) {
                 $fake_val = $title;
             }
             $selected = "";
             if ($element['std'] == $id || is_array($element['std']) && in_array($id, $element['std'])) {
                 $selected = "selected='selected'";
                 $fake_val = $title;
             }
             if ($base_url && str_replace($base_url, '{{AVIA_BASE_URL}}', $element['std']) == $id) {
                 $selected = "selected='selected'";
                 $fake_val = $title;
             }
             if (strpos($title, 'option_group_') === 0) {
                 $output .= "<optgroup label='" . $id . "'>";
             } else {
                 if (strpos($title, 'close_option_group_') === 0) {
                     $output .= "</optgroup>";
                 } else {
                     $output .= "<option {$selected} value='" . $id . "'>" . $title . "</option>";
                 }
             }
         }
     }
     $output .= '</select>';
     $output .= '<span class="avia_select_fake_val">' . $fake_val . '</span>';
     $output .= '</span></span>';
     if (isset($element['hook'])) {
         $output .= '<input type="hidden" name="' . $element['hook'] . '" value="' . $element['hook'] . '" />';
     }
     return $output;
 }
コード例 #3
0
 /**
  * 
  * The select method renders a single select element: it either lists custom values, all wordpress pages or all wordpress categories
  * @param array $element the array holds data like type, value, id, class, description which are necessary to render the whole option-section
  * @return string $output the string returned contains the html code generated within the method
  */
 static function select($element)
 {
     $select = __('Select', 'avia_framework');
     $parents = array();
     $fake_val = "";
     if ($element['subtype'] == 'cat') {
         $add_taxonomy = "";
         if (!empty($element['taxonomy'])) {
             $add_taxonomy = "&taxonomy=" . $element['taxonomy'];
         }
         $entries = get_categories('title_li=&orderby=name&hide_empty=0' . $add_taxonomy);
         //sort entries so subentries are displayed with indentation
         foreach ($entries as $key => $entry) {
             if ($entry->parent) {
                 $parents[$entry->parent][$entry->term_id] = $entry;
                 unset($entries[$key]);
             }
         }
     } else {
         if (!is_array($element['subtype'])) {
             global $wpdb;
             $table_name = $wpdb->prefix . "posts";
             $limit = apply_filters('avf_dropdown_post_number', 4000);
             if (isset(AviaHtmlHelper::$cache['entry_' + $limit]) && isset(AviaHtmlHelper::$cache['entry_' + $limit][$element['subtype']])) {
                 $entries = AviaHtmlHelper::$cache['entry_' + $limit][$element['subtype']];
             } else {
                 $prepare_sql = "SELECT distinct ID, post_title FROM {$table_name} WHERE post_status = 'publish' AND post_type = '" . $element['subtype'] . "' ORDER BY post_title ASC LIMIT {$limit}";
                 $prepare_sql = apply_filters('avf_dropdown_post_query', $prepare_sql, $table_name, $limit, $element);
                 $entries = $wpdb->get_results($prepare_sql);
                 AviaHtmlHelper::$cache['entry_' + $limit][$element['subtype']] = $entries;
             }
             //$entries 	= $wpdb->get_results( "SELECT ID, post_title FROM {$table_name} WHERE post_status = 'publish' AND post_type = '".$element['subtype']."' ORDER BY post_title ASC LIMIT {$limit}" );
             //$entries = get_posts(array('numberposts' => apply_filters( 'avf_dropdown_post_number', 200 ), 'post_type' => $element['subtype'], 'post_status'=> 'publish', 'orderby'=> 'post_date', 'order'=> 'ASC'));
         } else {
             $select = 'Select...';
             $entries = $element['subtype'];
             $add_entries = array();
             if (isset($element['folder'])) {
                 $add_file_array = avia_backend_load_scripts_by_folder(AVIA_BASE . $element['folder']);
                 if (is_array($add_file_array)) {
                     foreach ($add_file_array as $file) {
                         $skip = false;
                         if (!empty($element['exclude'])) {
                             foreach ($element['exclude'] as $exclude) {
                                 if (stripos($file, $exclude) !== false) {
                                     $skip = true;
                                 }
                             }
                         }
                         if (strpos($file, '.') !== 0 && $skip == false) {
                             $add_entries[$element['folderlabel'] . $file] = "{{AVIA_BASE_URL}}" . $element['folder'] . $file;
                         }
                     }
                     if (isset($element['group'])) {
                         $entries[$element['group']] = $add_entries;
                     } else {
                         $entries = array_merge($entries, $add_entries);
                     }
                 }
             }
         }
     }
     $data_string = "";
     if (isset($element['data'])) {
         foreach ($element['data'] as $key => $data) {
             $data_string .= "data-" . $key . "='" . $data . "'";
         }
     }
     if (empty($entries)) {
         return;
     }
     $multi = $multi_class = "";
     if (isset($element['multiple'])) {
         $multi_class = " avia_multiple_select";
         $multi = 'multiple="multiple" size="' . $element['multiple'] . '"';
         $element['std'] = explode(',', $element['std']);
     }
     $id_string = empty($element['id']) ? "" : "id='" . $element['id'] . "'";
     $name_string = empty($element['id']) ? "" : "name='" . $element['id'] . "'";
     $output = '<select ' . $multi . ' class="' . $element['class'] . '" ' . $id_string . ' ' . $name_string . ' ' . $data_string . '> ';
     if (isset($element['with_first'])) {
         $output .= '<option value="">' . $select . '</option>  ';
         $fake_val = $select;
     }
     $real_entries = array();
     foreach ($entries as $key => $entry) {
         if (!is_array($entry)) {
             $real_entries[$key] = $entry;
         } else {
             $real_entries['option_group_' . $key] = $key;
             foreach ($entry as $subkey => $subentry) {
                 $real_entries[$subkey] = $subentry;
             }
             $real_entries['close_option_group_' . $key] = "close";
         }
     }
     $entries = $real_entries;
     $output .= AviaHtmlHelper::create_select_option($element, $entries, $fake_val, $parents, 0);
     $output .= '</select>';
     return $output;
 }
コード例 #4
0
 /**
  * 
  * The select method renders a single select element: it either lists custom values, all wordpress pages or all wordpress categories
  * @param array $element the array holds data like type, value, id, class, description which are necessary to render the whole option-section
  * @return string $output the string returned contains the html code generated within the method
  */
 static function select($element)
 {
     $select = __('Select', 'avia_framework');
     if ($element['subtype'] == 'cat') {
         $add_taxonomy = "";
         if (!empty($element['taxonomy'])) {
             $add_taxonomy = "&taxonomy=" . $element['taxonomy'];
         }
         $entries = get_categories('title_li=&orderby=name&hide_empty=0' . $add_taxonomy);
     } else {
         if (!is_array($element['subtype'])) {
             global $wpdb;
             $table_name = $wpdb->prefix . "posts";
             $limit = apply_filters('avf_dropdown_post_number', 4000);
             $entries = $wpdb->get_results("SELECT ID, post_title FROM {$table_name} WHERE post_status = 'publish' AND post_type = '" . $element['subtype'] . "' ORDER BY post_title ASC LIMIT {$limit}");
             //$entries = get_posts(array('numberposts' => apply_filters( 'avf_dropdown_post_number', 200 ), 'post_type' => $element['subtype'], 'post_status'=> 'publish', 'orderby'=> 'post_date', 'order'=> 'ASC'));
         } else {
             $select = 'Select...';
             $entries = $element['subtype'];
             if (isset($element['folder'])) {
                 $add_file_array = avia_backend_load_scripts_by_folder(AVIA_BASE . $element['folder']);
                 if (is_array($add_file_array)) {
                     foreach ($add_file_array as $file) {
                         if (strpos($file, '.') !== 0) {
                             $entries[$element['folderlabel'] . $file] = AVIA_BASE_URL . $element['folder'] . $file;
                         }
                     }
                 }
             }
         }
     }
     $data_string = "";
     if (isset($element['data'])) {
         foreach ($element['data'] as $key => $data) {
             $data_string .= "data-" . $key . "='" . $data . "'";
         }
     }
     if (empty($entries)) {
         return;
     }
     $multi = $multi_class = "";
     if (isset($element['multiple'])) {
         $multi_class = " avia_multiple_select";
         $multi = 'multiple="multiple" size="' . $element['multiple'] . '"';
         $element['std'] = explode(',', $element['std']);
     }
     $id_string = empty($element['id']) ? "" : "id='" . $element['id'] . "'";
     $name_string = empty($element['id']) ? "" : "name='" . $element['id'] . "'";
     $output = '<select ' . $multi . ' class="' . $element['class'] . '" ' . $id_string . ' ' . $name_string . ' ' . $data_string . '> ';
     if (isset($element['with_first'])) {
         $output .= '<option value="">' . $select . '</option>  ';
         $fake_val = $select;
     }
     $real_entries = array();
     foreach ($entries as $key => $entry) {
         if (!is_array($entry)) {
             $real_entries[$key] = $entry;
         } else {
             $real_entries['option_group_' . $key] = $key;
             foreach ($entry as $subkey => $subentry) {
                 $real_entries[$subkey] = $subentry;
             }
             $real_entries['close_option_group_' . $key] = "close";
         }
     }
     $entries = $real_entries;
     foreach ($entries as $key => $entry) {
         if ($element['subtype'] == 'cat') {
             if (isset($entry->term_id)) {
                 $id = $entry->term_id;
                 $title = $entry->name;
             }
         } else {
             if (!is_array($element['subtype'])) {
                 $id = $entry->ID;
                 $title = $entry->post_title;
             } else {
                 $id = $entry;
                 $title = $key;
             }
         }
         if (!empty($title) || isset($title) && $title === 0) {
             if (!isset($fake_val)) {
                 $fake_val = $title;
             }
             $selected = "";
             if ($element['std'] == $id || is_array($element['std']) && in_array($id, $element['std'])) {
                 $selected = "selected='selected'";
                 $fake_val = $title;
             }
             if (strpos($title, 'option_group_') === 0) {
                 $output .= "<optgroup label='" . $id . "'>";
             } else {
                 if (strpos($title, 'close_option_group_') === 0) {
                     $output .= "</optgroup>";
                 } else {
                     $output .= "<option {$selected} value='" . $id . "'>" . $title . "</option>";
                 }
             }
         }
     }
     $output .= '</select>';
     return $output;
 }
コード例 #5
0
 function avia_sc_icon_box_add_icons()
 {
     $files = avia_backend_load_scripts_by_folder(AVIA_BASE . "images/icons/iconbox");
     $filestring = "";
     foreach ($files as $file) {
         $filestring .= ',"' . $file . '"';
     }
     $filestring = substr($filestring, 1);
     echo "\n <script type='text/javascript'>\n /* <![CDATA[ */  \n";
     echo "avia_framework_globals['iconbox_icons'] = [\n \t " . $filestring . "\n \t]; \n /* ]]> */ \n ";
     echo "</script>\n \n ";
 }