WordPress.org

Plugin Directory

Changeset 873764


Ignore:
Timestamp:
03/12/14 02:53:05 (15 months ago)
Author:
daggerhart
Message:

bug fix quick edit, clone form and output. only published widgets are displayed

Location:
widget-wrangler/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • widget-wrangler/trunk/README.txt

    r870328 r873764  
    2121= Survey = 
    2222 
    23 I've been working on an upgrade and would like to know how you use Widget Wrangler.  When you have a moment, please  
    24 [take my survey](https://docs.google.com/forms/d/1QOeLERlwWfUEWGe4o857RjgFvhkh54kOZfr5NJsLsPM/viewform) to help with future  
    25 development. 
     23I've been working on an upgrade and would like to know how you use Widget Wrangler. Please [take my survey](https://docs.google.com/forms/d/1QOeLERlwWfUEWGe4o857RjgFvhkh54kOZfr5NJsLsPM/viewform) to help with future development. 
    2624 
    2725= Screencasts = 
     
    9290 
    9391== Changelog == 
     92 
     93= 1.5.3 = 
     94 
     95* Fix: bug for cloned widget forms 
     96* Fix: bug on clone display when title hidden 
     97* Fix: bug on quick edit of widgets and posts 
     98* New: widgets only display if status is "publish" 
    9499 
    95100= 1.5.2 = 
     
    219224== Upgrade Notice == 
    220225 
    221 1.5.2 Bug fixes on new post creation and sortable widgets form 
     2261.5.3 Bug fixes on quick edits, clone forms and output.  Widget status must be 'publish' to display. 
  • widget-wrangler/trunk/admin/widget-wrangler.admin.php

    r854445 r873764  
    33 * Widget Wrangler Admin Panel and related functions 
    44 */ 
    5 function __jd($var){ 
    6   //print '<pre>'.print_r($var,1).'</pre>'; 
    7 } 
    85/* 
    96 * Handle the display of the admin panels, and loading of js & css 
     
    233230function ww_save_post($id) 
    234231{ 
     232  // skip quick edit 
     233  if (isset($_REQUEST['_inline_edit'])) { return; } 
     234 
    235235  // don't know what is being saved if not a post_type, so we do nothing 
    236236  if (!isset($_POST['post_type'])){ 
     
    320320function ww_admin_js(){ 
    321321  wp_enqueue_script('ww-admin-js', 
    322                   plugins_url('/ww-admin.js', __FILE__ ), 
     322                  WW_PLUGIN_URL.'/admin/ww-admin.js', 
    323323                  array('jquery-ui-core', 'jquery-ui-sortable'), 
    324324                  false); 
     
    344344function ww_sidebar_js(){ 
    345345  wp_enqueue_script('ww-sidebar-js', 
    346                     plugins_url('/admin/ww-sidebars.js', __FILE__ ), 
     346                     WW_PLUGIN_URL.'/admin/ww-sidebars.js', 
    347347                    array('jquery-ui-core', 'jquery-ui-sortable'), 
    348348                    false); 
  • widget-wrangler/trunk/admin/ww-clone.php

    r813996 r873764  
    4545  } 
    4646   
     47  $wp_widget = new $this_class_name; 
     48  $instance = $wp_widget->update($instance, array()); 
     49   
    4750  // prep new widget info for saving 
    4851  $new_widget = array(); 
     
    8083function ww_make_clone_instance($posted){ 
    8184    global $wp_widget_factory; 
    82     $clone_class = $posted['ww-data']['clone']['clone-class']; 
    83   $option_name = "widget-".$wp_widget_factory->widgets[$clone_class]->control_options['id_base']; 
    84   $instance = array(); 
    85    
    86   // loop through instance values and create an instance array 
    87     foreach($posted[$option_name] as $i => $settings){ 
    88         foreach($settings as $key => $value){ 
    89             $instance[$key] = $value; 
    90         } 
    91     } 
    92    
    93     return $instance; 
     85    if (isset($posted['ww-data'])){ 
     86    $clone_class = $posted['ww-data']['clone']['clone-class']; 
     87    $option_name = "widget-".$wp_widget_factory->widgets[$clone_class]->control_options['id_base']; 
     88    $instance = array(); 
     89     
     90    // loop through instance values and create an instance array 
     91    foreach($posted[$option_name] as $i => $settings){ 
     92      foreach($settings as $key => $value){ 
     93        $instance[$key] = $value; 
     94      } 
     95    } 
     96     
     97    return $instance; 
     98  } 
     99  return false; 
    94100} 
    95101/* 
     
    109115    <ul class='ww-clone-widgets'> 
    110116    <?php 
    111       foreach ($wp_widget_factory->widgets as $class_name => $widget) 
     117      foreach ($wp_widget_factory->widgets as $classname => $widget) 
    112118      { 
    113119        $posted_array_key = "widget-".$widget->id_base; 
     
    121127         
    122128        ob_start(); 
    123         eval('$w = new '.$class_name.'(); $w->form(array());'); 
     129          $wp_widget = new $classname; 
     130          $wp_widget->form(array()); 
    124131        $new_class_form = ob_get_clean(); 
    125132        ?> 
     
    134141              <div class='widget-inside'>             
    135142                <form action='edit.php?post_type=widget&page=ww-clone&ww-clone-action=insert&noheader=true' method='post'> 
    136                   <input type='hidden' name='ww-classname' value='<?php print $class_name; ?>' /> 
     143                  <input type='hidden' name='ww-classname' value='<?php print $classname; ?>' /> 
    137144                  <input type='hidden' name='ww-keyname' value='<?php print $posted_array_key; ?>' /> 
    138145                  <?php print $new_class_form; ?> 
  • widget-wrangler/trunk/common/widget-display.inc

    r813996 r873764  
    5858function ww_theme_single_widget($widget) 
    5959{ 
     60  if (empty($widget)) { return ''; } 
     61   
    6062  // clone 
    6163  if ($widget->widget_type == "clone"){ 
     
    209211  // load widget from widget factory ? 
    210212  global $wp_widget_factory; 
    211   $wp_widget_class_obj = $wp_widget_factory->widgets[$wp_widget_class]; 
     213  $wp_widget = $wp_widget_factory->widgets[$wp_widget_class]; 
    212214 
    213215  // get as much ww widget data as possible  
    214216  $ww_widget = (isset($instance['ww_widget'])) ? $instance['ww_widget'] : ww_get_single_widget($instance['ID']); 
    215217   
    216   if ( !is_a($wp_widget_class_obj, 'WP_Widget') ) 
     218  if ( !is_a($wp_widget, 'WP_Widget') ) 
    217219   return; 
    218220 
     
    222224  // output to variable for replacements 
    223225  ob_start(); 
    224      $wp_widget_class_obj->widget($args, $instance); 
     226     $wp_widget->widget($args, $instance); 
    225227  $temp = ob_get_clean(); 
    226228 
     
    229231 
    230232  // prep object for template 
    231   $ww_widget->post_title    = ($array[0]) ? $array[0]: $instance['title']; 
    232   $ww_widget->post_content  = $array[1]; 
     233  if (count($array) > 1) { 
     234    // we have a title 
     235    $ww_widget->post_title    = ($array[0]) ? $array[0]: $instance['title']; 
     236    $ww_widget->post_content  = $array[1]; 
     237  } 
     238  else { 
     239    // no title 
     240    $ww_widget->post_content = $array[0]; 
     241  } 
    233242 
    234243  if (isset($instance['hide_title']) && $instance['hide_title']){ 
  • widget-wrangler/trunk/common/ww-widget-class.php

    r814502 r873764  
    157157  function wp_insert_post($post_id, $post = null) 
    158158  { 
    159     //Check if this call results from another event, like the "Quick Edit" option 
    160     // http://wordpress.org/support/topic/plugin-widget-wrangler-adv-parsing-gets-lost-after-quickedit 
    161         if (isset($_POST['quickeditfix']) && $_POST['quickeditfix'] != "true") { return; } 
     159    // Check if this call results from another event, like the "Quick Edit" option 
     160    // http://wordpress.org/support/topic/quickedit-deletes-code-in-advanced-parsing?replies=1 
     161        if (isset($_REQUEST['_inline_edit'])) { return; } 
    162162 
    163163    if ($post->post_type == "widget") 
     
    196196      if ($widget_type == "clone"){ 
    197197        $instance = ww_make_clone_instance($_POST); 
     198        $old_instance = get_post_meta($post_id, 'ww-clone-instance', true); 
     199         
     200        // let the widget update itself 
     201        $classname = $_POST['ww-data']['clone']['clone-class']; 
     202        if (class_exists($classname)) { 
     203          $wp_widget = new $classname; 
     204          $instance = $wp_widget->update($instance, $old_instance); 
     205        } 
     206         
    198207        $instance['ID'] = $post_id; 
    199208        if (isset($_POST['ww-data']['clone']['hide_title'])){ 
     
    235244    $wp_widget_instance = get_post_meta($this->post_id, 'ww-clone-instance', true); 
    236245     
    237     //var_dump($wp_widget_instance); 
    238      
    239246    if($wp_widget_classname) 
    240247    { 
    241248      // create instance form 
    242249      ob_start(); 
    243         eval('$w = new '.$wp_widget_classname.'(); $w->form($wp_widget_instance);'); 
    244         $instance_form = ob_get_clean(); 
     250        $wp_widget = new $wp_widget_classname; 
     251        $wp_widget->form($wp_widget_instance); 
     252      $instance_form = ob_get_clean(); 
    245253         
    246254      $hide_title_checked = (isset($wp_widget_instance['hide_title'])) ? 'checked="checked"' : ''; 
     
    254262                <input type="hidden" name="ww-data[clone][clone-class]" value="<?php print $wp_widget_classname; ?>" /> 
    255263        <input type="hidden" name="ww-data[clone][clone-instance]" value="Placeholder" /> 
    256         <input type="hidden" name="quickeditfix" value="true" /> 
    257264      <?php 
    258265    } 
     
    387394                  <div> 
    388395                    <h4>WP_Widget $instance</h4> 
    389                     <div><pre><?php print_r($clone_instance); ?></pre></div> 
     396                    <div><pre><?php print htmlentities(print_r($clone_instance,1)); ?></pre></div> 
    390397                  </div> 
    391398                  <?php 
  • widget-wrangler/trunk/widget-wrangler.php

    r860333 r873764  
    55Description: Widget Wrangler gives the wordpress admin a clean interface for managing widgets on a page by page basis. It also provides widgets as a post type, the ability to clone existing wordpress widgets, and granular control over widgets' templates. 
    66Author: Jonathan Daggerhart 
    7 Version: 1.5.2 
     7Version: 1.5.3 
     8 
    89Author URI: http://www.websmiths.co 
    910License: GPL2 
     
    133134 * @return widget object 
    134135 */ 
    135 function ww_get_single_widget($post_id){ 
     136function ww_get_single_widget($post_id, $widget_status = false){ 
    136137  global $wpdb; 
     138   
     139  $status = $widget_status ? ("`post_status` = '".$widget_status."' AND") : ""; 
    137140   
    138141  $query = "SELECT 
     
    142145            WHERE 
    143146              `post_type` = 'widget' AND 
     147              ". $status ." 
    144148              `ID` = ".$post_id." LIMIT 1"; 
    145149  if ($widget = $wpdb->get_row($query)) { 
     
    213217    while($i < $total) 
    214218    { 
    215       if($widget = ww_get_single_widget($widgets_array[$sidebar_slug][$i]['id'])) 
     219      if($widget = ww_get_single_widget($widgets_array[$sidebar_slug][$i]['id'], 'publish')) 
    216220      { 
    217221        // include theme compatibility data 
     
    242246  $short_array = shortcode_atts(array('id' => ''), $atts); 
    243247  extract($short_array); 
    244   return ww_theme_single_widget(ww_get_single_widget($id)); 
     248  if ($widget = ww_get_single_widget($id, 'publish')){ 
     249    return ww_theme_single_widget($widget); 
     250  } 
     251  return ''; 
    245252} 
    246253 
Note: See TracChangeset for help on using the changeset viewer.