Ejemplo n.º 1
0
 /**
  * ajax controller. Loads an ajax_view test
  */
 function ajax_view_controller()
 {
     //if user is logged in and can switch themes
     if (current_user_can('switch_themes')) {
         // read some of the variables
         $td_ajax_calling_file = td_util::get_http_post_val('td_ajax_calling_file');
         $td_ajax_box_id = td_util::get_http_post_val('td_ajax_box_id');
         $td_ajax_calling_file_id = str_replace('.php', '', $td_ajax_calling_file);
         //get the calling file id so we can look it up in our td_global panel list array
         $buffy = '';
         // load the ajax view only if we find it in the panel list form td_global
         foreach (td_global::$theme_panels_list as $panel_id => $panel_array) {
             if (!empty($panel_array['file_id']) and $panel_array['file_id'] == $td_ajax_calling_file_id) {
                 /**
                  * search for the ajax file in
                  * 1. includes/panel/views/ajax_boxes/$td_ajax_calling_file_id/$td_ajax_box_id.php
                  * 2. in includes/wp_booster/wp-admin/panel/ajax_boxes/$td_ajax_calling_file_id/$td_ajax_box_id.php
                  */
                 ob_start();
                 $td_template_found_in_theme_or_child = locate_template('includes/panel/views/ajax_boxes/' . $td_ajax_calling_file_id . '/' . $td_ajax_box_id . '.php', true);
                 if (empty($td_template_found_in_theme_or_child)) {
                     require_once 'views/ajax_boxes/' . $td_ajax_calling_file_id . '/' . $td_ajax_box_id . '.php';
                 }
                 $buffy = ob_get_clean();
                 break;
             }
         }
         if (empty($buffy)) {
             $buffy = 'No ajax panel found OR Panel is empty! <br> ' . __FILE__;
         }
         // each panel has to have a td-clear at the end
         $buffy .= '<div class="td-clear"></div>';
         //return the view counts
         die(json_encode($buffy));
     } else {
         die;
     }
     //end if user can switch themes
 }
<?php

/**
 * Created by ra on 1/13/2015.
 */
$taxonomy_name = td_util::get_http_post_val('taxonomy_name');
?>





<!-- DISPLAY VIEW -->
<div class="td-box-row">
    <div class="td-box-description">
        <span class="td-box-title">ARTICLE DISPLAY VIEW</span>
        <p>Select a module type, this is how your article list will be displayed. For custom modules or tuning, read <a target="_blank" href="http://forum.tagdiv.com/api-modules-introduction/">the module API</a></p>
    </div>
    <div class="td-box-control-full td-panel-module">
        <?php 
echo td_panel_generator::visual_select_o(array('ds' => 'td_taxonomy', 'item_id' => $taxonomy_name, 'option_id' => 'tds_taxonomy_page_layout', 'values' => td_panel_generator::helper_display_modules('enabled_on_loops')));
?>
    </div>
</div>



<!-- Custom Sidebar + position -->
<div class="td-box-row">
    <div class="td-box-description">
        <span class="td-box-title">CUSTOM SIDEBAR + POSITION</span>
Ejemplo n.º 3
0
function td_ajax_loop()
{
    $loopState = td_util::get_http_post_val('loopState');
    //print_r($loopState);
    $buffy = '';
    /**
     * @var WP_Query
     */
    $td_query =& td_data_source::get_wp_query($loopState['atts'], $loopState['currentPage']);
    //by ref  do the query
    if (!empty($td_query->posts)) {
        td_global::$is_wordpress_loop = true;
        ///if we are in wordpress loop; used by quotes in blocks to check if the blocks are displayed in blocks or in loop
        $td_template_layout = new td_template_layout($loopState['sidebarPosition']);
        $td_module_class = td_util::get_module_class_from_loop_id($loopState['moduleId']);
        //disable the grid for some of the modules
        $td_module_api = td_api_module::get_by_id($td_module_class);
        if ($td_module_api['uses_columns'] === false) {
            $td_template_layout->disable_output();
        }
        foreach ($td_query->posts as $post) {
            $buffy .= $td_template_layout->layout_open_element();
            if (class_exists($td_module_class)) {
                $td_mod = new $td_module_class($post);
                $buffy .= $td_mod->render();
            } else {
                td_util::error(__FILE__, 'Missing module: ' . $td_module_class);
            }
            $buffy .= $td_template_layout->layout_close_element();
            $td_template_layout->layout_next();
        }
        $buffy .= $td_template_layout->close_all_tags();
    } else {
        // no posts
    }
    $loopState['server_reply_html_data'] = $buffy;
    die(json_encode($loopState));
}
Ejemplo n.º 4
0
 /**
  * Loads the ajax box content
  */
 static function load_ajax_box()
 {
     //if user is logged in and can switch themes
     if (current_user_can('switch_themes')) {
         // read some of the variables
         $td_ajax_calling_file = td_util::get_http_post_val('td_ajax_calling_file');
         $td_ajax_box_id = td_util::get_http_post_val('td_ajax_box_id');
         $td_current_panel_spot_id = td_util::get_http_post_val('td_current_theme_panel_id');
         $td_ajax_calling_file_id = str_replace('.php', '', $td_ajax_calling_file);
         //get the calling file id so we can look it up in our td_global panel list array
         $buffy = '';
         foreach (td_global::$all_theme_panels_list[$td_current_panel_spot_id]['panels'] as $panel_id => $panel_array) {
             // locate the entry for this specific panel spot -> panel by using the 'file' key
             if (isset($panel_array['file']) and strpos($panel_array['file'], $td_ajax_calling_file) !== false) {
                 if ($panel_array['type'] == 'in_theme') {
                     // if the panel is in theme, we have to look for it in the theme's /panel folder and only after that in the wp-booster panel
                     ob_start();
                     $td_template_found_in_theme_or_child = locate_template('includes/panel/views/ajax_boxes/' . $td_ajax_calling_file_id . '/' . $td_ajax_box_id . '.php', true);
                     if (empty($td_template_found_in_theme_or_child)) {
                         require_once TEMPLATEPATH . '/includes/wp_booster/wp-admin/panel/views/ajax_boxes/' . $td_ajax_calling_file_id . '/' . $td_ajax_box_id . '.php';
                     }
                     $buffy = ob_get_clean();
                 } elseif ($panel_array['type'] == 'in_plugin') {
                     // the panel is in a plugin. Here we look in the plugins folder and we patch the path for this specific plugin
                     $folder_path = dirname($panel_array['file']);
                     $ajax_box_plugin_path = $folder_path . '/' . $td_ajax_calling_file_id . '/' . $td_ajax_box_id;
                     if (file_exists($ajax_box_plugin_path)) {
                         ob_start();
                         require_once $ajax_box_plugin_path;
                         $buffy = ob_get_clean();
                     }
                 }
                 break;
                 // we found our item and we tried to load it, now exit the loop
             }
         }
         if (empty($buffy)) {
             $buffy = 'No ajax panel found OR Panel is empty! <br> ' . __FILE__;
         }
         // each panel has to have a td-clear at the end
         $buffy .= '<div class="td-clear"></div>';
         //return the view counts
         die(json_encode($buffy));
     } else {
         die;
     }
     //end if user can switch themes
 }
 static function ajax_view_controller()
 {
     //if user is logged in and can switch themes
     if (current_user_can('switch_themes')) {
         // what view to load?
         $td_ajax_view = td_util::get_http_post_val('td_ajax_view');
         $buffy = '';
         switch ($td_ajax_view) {
             //@todo trebuie refacuta
             case 'td_thumbs':
                 require_once 'ajax_views/td_block_settings_ajax.php';
                 $buffy = td_block_settings_ajax::thumbs_panel();
                 break;
             case 'td_category':
                 require_once 'ajax_views/td_category.php';
                 $buffy = td_category_form_ajax(td_util::get_http_post_val('category_id'));
                 break;
             case 'td_translations':
                 require_once 'ajax_views/td_translations.php';
                 $buffy = td_translations_form_ajax();
                 break;
             case 'td_theme_fonts':
                 //start section
                 $td_start_section = intval(json_decode($_POST['start_section']));
                 //end section
                 $td_end_section = intval(json_decode($_POST['end_section']));
                 require_once 'ajax_views/td_theme_fonts.php';
                 $object_custom_typography_ajax = new td_panel_custom_typography_ajax();
                 $buffy = $object_custom_typography_ajax->td_custom_typology_generate_font_controls(array($td_start_section, $td_end_section));
                 break;
         }
         // each panel has to have a td-clear at the end
         $buffy .= '<div class="td-clear"></div>';
         //return the view counts
         die(json_encode($buffy));
     } else {
         die;
     }
     //end if user can switch themes
 }
Ejemplo n.º 6
0
<?php

$ad_spot_id = td_util::get_http_post_val('ad_spot_id');
//google ad list sizes
$td_google_ad_list_sizes = array(array('text' => 'Auto', 'val' => ''), array('text' => '120 x 90', 'val' => '120 x 90'), array('text' => '120 x 240', 'val' => '120 x 240'), array('text' => '120 x 600', 'val' => '120 x 600'), array('text' => '125 x 125', 'val' => '125 x 125'), array('text' => '160 x 90', 'val' => '160 x 90'), array('text' => '160 x 600', 'val' => '160 x 600'), array('text' => '180 x 90', 'val' => '180 x 90'), array('text' => '180 x 150', 'val' => '180 x 150'), array('text' => '200 x 90', 'val' => '200 x 90'), array('text' => '200 x 200', 'val' => '200 x 200'), array('text' => '234 x 60', 'val' => '234 x 60'), array('text' => '250 x 250', 'val' => '250 x 250'), array('text' => '320 x 100', 'val' => '320 x 100'), array('text' => '300 x 250', 'val' => '300 x 250'), array('text' => '300 x 600', 'val' => '300 x 600'), array('text' => '320 x 50', 'val' => '320 x 50'), array('text' => '336 x 280', 'val' => '336 x 280'), array('text' => '468 x 15', 'val' => '468 x 15'), array('text' => '468 x 60', 'val' => '468 x 60'), array('text' => '728 x 15', 'val' => '728 x 15'), array('text' => '728 x 90', 'val' => '728 x 90'), array('text' => '970 x 90', 'val' => '970 x 90'), array('text' => '240 x 400 - Regional ad sizes', 'val' => '240 x 400'), array('text' => '250 x 360 - Regional ad sizes', 'val' => '250 x 360'), array('text' => '580 x 400 - Regional ad sizes', 'val' => '580 x 400'), array('text' => '750 x 100 - Regional ad sizes', 'val' => '750 x 100'), array('text' => '750 x 200 - Regional ad sizes', 'val' => '750 x 200'), array('text' => '750 x 300 - Regional ad sizes', 'val' => '750 x 300'), array('text' => '980 x 120 - Regional ad sizes', 'val' => '980 x 120'), array('text' => '930 x 180 - Regional ad sizes', 'val' => '930 x 180'));
?>

<!-- ad box code -->
<div class="td-box-row">
    <div class="td-box-description">
        <span class="td-box-title">YOUR AD CODE</span>
        <p>Paste your ad code here. Google adsense will be made responsive automatically. <br><br> To add non adsense responsive ads, <br> <a target="_blank" href="http://forum.tagdiv.com/ads-system-full-guide/">click here</a> (last paragraph)</p>
    </div>
    <div class="td-box-control-full">
        <?php 
echo td_panel_generator::textarea(array('ds' => 'td_ads', 'item_id' => $ad_spot_id, 'option_id' => 'ad_code'));
?>
    </div>
</div>


<div class="td-box-row">
    <div class="td-box-description td-box-full">
        <span class="td-box-title">Advance usage:</span>
        <p>If you leave the AdSense size boxes on Auto, the theme will automatically resize the <strong>google ads</strong>. For more info follow this <a href="http://forum.tagdiv.com/ads-system-full-guide/" target="_blank">link</a></p>
    </div>
    <div class="td-box-row-margin-bottom"></div>
</div>


<!-- disable ad on monitor -->
<?php

/**
 * Created by ra on 1/13/2015.
 */
$category_id = td_util::get_http_post_val('category_id');
?>


    <!-- Category template -->
    <div class="td-box-row">
        <div class="td-box-description">
            <span class="td-box-title">分类模板</span>
            <p>这是分类页眉</p>
        </div>
        <div class="td-box-control-full">
            <?php 
echo td_panel_generator::visual_select_o(array('ds' => 'td_category', 'item_id' => $category_id, 'option_id' => 'tdc_category_template', 'values' => td_api_category_template::_helper_to_panel_values('default+get_all')));
?>
        </div>
    </div>



<div class="td-box-section-separator"></div>
    <!-- Category top posts style -->
    <div class="td-box-row">
        <div class="td-box-description">
            <span class="td-box-title">分类顶部文章风格</span>
            <p>设置页脚布局</p>
        </div>
<?php

/**
 * Created by ra on 7/9/2015.
 */
$custom_post_type = td_util::get_http_post_val('custom_post_type');
// get the registered taxonomies for this specific post type and prepare them for use in the panels dropdowns
// add empty
$td_registered_taxonomies[] = array('val' => '', 'text' => '-- None --');
// read the taxonomies and build the array
$registered_taxonomies_obj = get_object_taxonomies($custom_post_type, 'objects');
foreach ($registered_taxonomies_obj as $registered_taxonomy_obj) {
    $td_registered_taxonomies[] = array('val' => $registered_taxonomy_obj->name, 'text' => $registered_taxonomy_obj->labels->name . '  ' . '(' . $registered_taxonomy_obj->name . ')');
}
?>





<!-- breadcrumbs: select taxonomy -->
<div class="td-box-row">
    <div class="td-box-description">
        <span class="td-box-title">Breadcrumbs taxonomy</span>
        <p>What taxonomy should show up in the breadcrumbs</p>
    </div>
    <div class="td-box-control-full">
        <?php 
echo td_panel_generator::dropdown(array('ds' => 'td_cpt', 'item_id' => $custom_post_type, 'option_id' => 'tds_breadcrumbs_taxonomy', 'values' => $td_registered_taxonomies));
?>
    </div>
    public function td_custom_typology_generate_font_controls()
    {
        ob_start();
        //get the sections start and end
        $section_name = td_util::get_http_post_val('section_name');
        ?>
		<div class="td-panel-fonts-header">
		    <div class="td-panel-font-description td-panel-font-family">Font family</div>
			<div class="td-panel-font-description td-panel-font-size">Size</div>
		    <div class="td-panel-font-description td-panel-font-line-height">Line height</div>
		    <div class="td-panel-font-description td-panel-font-style">Style</div>
		    <div class="td-panel-font-description td-panel-font-weight">Weight</div>
		    <div class="td-panel-font-description td-panel-font-transform">Transform</div>
		</div>
	    <?php 
        foreach (td_global::$typography_settings_list[$section_name] as $font_setting_id => $font_setting) {
            ?>
                <div class="td-box-row td-panel-font-typography">
	                <div class="td-box-description">

	                    <span class="td-box-title td-title-on-row">
		                    <?php 
            echo $font_setting['text'];
            ?>
	                    </span>
	                </div>
	                <div class="td-box-control-full">

		                <div class="td-panel-font-family">
			                <?php 
            echo td_panel_generator::dropdown(array('ds' => 'td_fonts', 'item_id' => $font_setting_id, 'option_id' => 'font_family', 'values' => $this->td_typology_fonts_array));
            ?>
		                </div>

	                    <?php 
            if ($font_setting['type'] != 'general_setting') {
                ?>

		                    <div class="td-panel-font-size">
			                    <?php 
                echo td_panel_generator::dropdown(array('ds' => 'td_fonts', 'item_id' => $font_setting_id, 'option_id' => 'font_size', 'values' => $this->td_font_size_list));
                ?>
		                    </div>
		                    <div class="td-panel-font-line-height">
		                        <?php 
                echo td_panel_generator::dropdown(array('ds' => 'td_fonts', 'item_id' => $font_setting_id, 'option_id' => 'line_height', 'values' => $this->td_line_height_list));
                ?>
		                    </div>
		                    <div class="td-panel-font-style">
		                        <?php 
                echo td_panel_generator::dropdown(array('ds' => 'td_fonts', 'item_id' => $font_setting_id, 'option_id' => 'font_style', 'values' => $this->td_font_style_list));
                ?>
		                    </div>
		                    <div class="td-panel-font-weight">
		                        <?php 
                echo td_panel_generator::dropdown(array('ds' => 'td_fonts', 'item_id' => $font_setting_id, 'option_id' => 'font_weight', 'values' => $this->td_font_weight));
                ?>
		                    </div>
		                    <div class="td-panel-font-transform">
		                        <?php 
                echo td_panel_generator::dropdown(array('ds' => 'td_fonts', 'item_id' => $font_setting_id, 'option_id' => 'text_transform', 'values' => $this->td_text_transform));
                ?>
		                    </div>

	                    <?php 
            }
            ?>

	                </div>
                </div><?php 
        }
        //end foreach
        return ob_get_clean();
    }
Ejemplo n.º 10
0
 function ajax_stacks_controller()
 {
     if (!current_user_can('switch_themes')) {
         echo 'Permission denied!';
     }
     // try to extend the time limit
     @set_time_limit(240);
     $td_demo_action = td_util::get_http_post_val('td_demo_action');
     $td_demo_id = td_util::get_http_post_val('td_demo_id');
     /*  ----------------------------------------------------------------------------
            Uninstall button - do uninstall with content
         */
     if ($td_demo_action == 'uninstall_demo') {
         // remove our content
         td_demo_media::remove();
         td_demo_content::remove();
         td_demo_category::remove();
         td_demo_menus::remove();
         td_demo_widgets::remove();
         // restore all settings to the state before a demo was loaded
         $td_demo_history = new td_demo_history();
         $td_demo_history->restore_all();
         // update our state - no stack installed
         td_demo_state::update_state('', '');
     } else {
         if ($td_demo_action == 'remove_content_before_install_no_content') {
             // save the history - this class will save the history only when going from user settings -> stack
             $td_demo_history = new td_demo_history();
             $td_demo_history->save_all();
             // clean the user settings
             td_demo_media::remove();
             td_demo_content::remove();
             td_demo_category::remove();
             td_demo_menus::remove();
             td_demo_widgets::remove();
             // remove panel settings and recompile the css as empty
             foreach (td_global::$td_options as $option_id => $option_value) {
                 td_global::$td_options[$option_id] = '';
             }
             //typography settings
             td_global::$td_options['td_fonts'] = '';
             //css font files (google) buffer
             td_global::$td_options['td_fonts_css_files'] = '';
             //compile user css if any
             td_global::$td_options['tds_user_compile_css'] = td_css_generator();
             update_option(TD_THEME_OPTIONS_NAME, td_global::$td_options);
         } else {
             if ($td_demo_action == 'install_no_content_demo') {
                 td_demo_state::update_state($td_demo_id, 'no_content');
                 // load panel settings - this will also recompile the css
                 $this->import_panel_settings(td_global::$demo_list[$td_demo_id]['folder'] . 'td_panel_settings.txt', false);
             } else {
                 if ($td_demo_action == 'remove_content_before_install') {
                     // save the history - this class will save the history only when going from user settings -> stack
                     $td_demo_history = new td_demo_history();
                     $td_demo_history->save_all();
                     // clean the user settings
                     td_demo_media::remove();
                     td_demo_content::remove();
                     td_demo_category::remove();
                     td_demo_menus::remove();
                     td_demo_widgets::remove();
                 } else {
                     if ($td_demo_action == 'td_media_1') {
                         // change our state
                         td_demo_state::update_state($td_demo_id, 'full');
                         // load panel settings
                         $this->import_panel_settings(td_global::$demo_list[$td_demo_id]['folder'] . 'td_panel_settings.txt', true);
                         // load the media import script
                         require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_1.php';
                     } else {
                         if ($td_demo_action == 'td_media_2') {
                             // load the media import script
                             require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_2.php';
                         } else {
                             if ($td_demo_action == 'td_media_3') {
                                 // load the media import script
                                 require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_3.php';
                             } else {
                                 if ($td_demo_action == 'td_media_4') {
                                     // load the media import script
                                     require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_4.php';
                                 } else {
                                     if ($td_demo_action == 'td_media_5') {
                                         // load the media import script
                                         require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_5.php';
                                     } else {
                                         if ($td_demo_action == 'td_media_6') {
                                             // load the media import script
                                             require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_media_6.php';
                                         } else {
                                             if ($td_demo_action == 'td_import') {
                                                 require_once td_global::$demo_list[$td_demo_id]['folder'] . 'td_import.php';
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Function hook used for 'save_post' wp hook
  */
 function on_save_post($post_id)
 {
     $post_type = get_post_type($post_id);
     if (!in_array($post_type, $this->post_types)) {
         return;
     }
     $td_demo_action = td_util::get_http_post_val('td_demo_action');
     if (empty($td_demo_action) and !empty($_POST) and check_admin_referer('post.php', self::get_nonce_field($post_id)) and isset($_POST[$this->editor_id])) {
         update_post_meta($post_id, $this->meta_key, $_POST[$this->editor_id]);
     }
 }