コード例 #1
0
 public function migrate_if_needed()
 {
     // Get current migrated to version
     $migrate_version = get_option('wpupg_migrate_version', false);
     if (!$migrate_version) {
         $notices = false;
         $migrate_version = '0.0.1';
     } else {
         $notices = true;
     }
     $migrate_special = '';
     if (isset($_GET['wpupg_migrate'])) {
         $migrate_special = $_GET['wpupg_migrate'];
     }
     if ($migrate_version < '1.2') {
         require_once WPUltimatePostGrid::get()->coreDir . '/helpers/migration/1_2_active_colors.php';
     }
     // Each version update once
     if ($migrate_version < WPUPG_VERSION) {
         WPUltimatePostGrid::addon('custom-templates')->default_templates(true);
         // Reset default templates
         // Update all grid caches
         $args = array('post_type' => WPUPG_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'nopaging' => true, 'fields' => 'ids');
         $query = new WP_Query($args);
         $posts = $query->have_posts() ? $query->posts : array();
         $grid_ids = array_map('intval', $posts);
         if (count($grid_ids) > 0) {
             update_option('wpupg_regenerate_grids_check', $grid_ids);
         }
         update_option('wpupg_migrate_version', WPUPG_VERSION);
     }
 }
コード例 #2
0
 public function activate_plugin()
 {
     WPUltimatePostGrid::addon('custom-templates')->default_templates(true);
     // Reset default templates
     // Don't show the activation notice if the new user notice is displayed
     if (get_user_meta(get_current_user_id(), '_wpupg_hide_new_notice', true) != '') {
         $this->activation_notice();
     }
 }
コード例 #3
0
function wpupg_admin_template_editor()
{
    if (WPUltimatePostGrid::is_addon_active('template-editor')) {
        $url = WPUltimatePostGrid::addon('template-editor')->editor_url();
        $button = '<a href="' . $url . '" class="button button-primary" target="_blank">' . __('Open the Template Editor', 'wp-ultimate-post-grid') . '</a>';
    } else {
        $button = '<a href="#" class="button button-primary button-disabled" disabled>' . __('Open the Template Editor', 'wp-ultimate-post-grid') . '</a>';
    }
    return $button;
}
コード例 #4
0
 public function output($post, $args = array())
 {
     if (!$this->output_block($post, $args)) {
         return '';
     }
     if ($this->preset) {
         $this->url = WPUltimatePostGrid::addon('template-editor')->addonUrl . '/img/' . $this->preset . '.png';
     }
     $output = $this->before_output();
     $output .= '<img src="' . $this->url . '"' . $this->style() . '\\>';
     return $this->after_output($output, $post);
 }
コード例 #5
0
 public function template()
 {
     return WPUltimatePostGrid::addon('custom-templates')->get_template($this->template_id());
 }
コード例 #6
0
ファイル: meta_box_grid.php プロジェクト: anniesmidt/bfjn
            </select>
        </td>
        <td><?php 
_e('Options for links surrounding the grid items.', 'wp-ultimate-post-grid');
?>
</td>
    </tr>
    <tr class="wpupg_divider">
        <td><label for="wpupg_template"><?php 
_e('Template', 'wp-ultimate-post-grid');
?>
</label></td>
        <td>
            <select name="wpupg_template" id="wpupg_template" class="wpupg-select2">
                <?php 
$templates = WPUltimatePostGrid::addon('custom-templates')->get_mapping();
$templates = apply_filters('wpupg_meta_box_grid_templates', $templates);
foreach ($templates as $index => $template) {
    $selected = $index == $grid->template_id() ? ' selected="selected"' : '';
    echo '<option value="' . esc_attr($index) . '"' . $selected . '>' . $template . '</option>';
}
?>
            </select>
        </td>
        <td><?php 
_e('Template to be used for grid items.', 'wp-ultimate-post-grid');
?>
</td>
    </tr>
    <tr>
        <td><label for="wpupg_layout_mode"><?php 
コード例 #7
0
 protected function before_output()
 {
     $output = '';
     // Responsive
     if (!$this->show_on_desktop) {
         $output = '<div class="wpupg-responsive-mobile">';
     } else {
         if (!$this->show_on_mobile) {
             $output = '<div class="wpupg-responsive-desktop">';
         }
     }
     // Background presets
     if ($this->background_preset) {
         switch ($this->background_preset) {
             case 'default':
                 $img = WPUltimatePostGrid::addon('custom-templates')->addonUrl . '/img/default.png';
                 break;
             default:
                 $img = WPUltimatePostGrid::addon('template-editor')->addonUrl . '/img/' . $this->background_preset . '.png';
         }
         if (isset($img)) {
             $this->add_style('background', 'url(' . $img . ')');
         }
     }
     return $output;
 }