Plugin Directory

Changeset 608822


Ignore:
Timestamp:
10/06/2012 07:38:11 AM (13 years ago)
Author:
ti2m
Message:

Shortcode support

Location:
edge-suite/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • edge-suite/trunk/admin/options.php

    r602441 r608822  
    4848
    4949      <tr valign="top">
     50          <th scope="row">Widget shortcode</th>
     51          <td>
     52            <?php
     53            $selected = intval(get_option('edge_suite_widget_shortcode')) == 1 ? 'checked="checked"' : '';
     54            ?>
     55            <p><input type="checkbox" name="edge_suite_widget_shortcode" value="1" <?php echo $selected; ?>"/>
     56                Enable usage of shortcodes in widgets</p>
     57          </td>
     58      </tr>
     59
     60      <tr valign="top">
    5061          <th scope="row">Deactivation deletion</th>
    5162          <td>
  • edge-suite/trunk/edge-suite.php

    r608323 r608822  
    8989  add_option('edge_suite_comp_homepage', 0);
    9090  add_option('edge_suite_deactivation_delete', 0);
     91  add_option('edge_suite_widget_shortcode', 0);
    9192
    9293  // Create main edge suite directory.
     
    115116    delete_option('edge_suite_comp_homepage');
    116117    delete_option('edge_suite_deactivation_delete');
     118    delete_option('edge_suite_widget_shortcode');
    117119  }
    118120}
     
    130132  register_setting('edge_suite_options', 'edge_suite_comp_homepage');
    131133  register_setting('edge_suite_options', 'edge_suite_deactivation_delete');
     134  register_setting('edge_suite_options', 'edge_suite_widget_shortcode');
    132135}
    133136
     
    344347  $options = array();
    345348  foreach ($definitions as $definition) {
    346     $options[$definition->definition_id] = $definition->project_name . ' ' . $definition->composition_id;
     349    $options[$definition->definition_id] = $definition->definition_id . ' - ' . $definition->project_name . ' ' . $definition->composition_id;
    347350  }
    348351
     
    367370}
    368371
     372/**
     373 * Shortcode implementation for 'edge_animation'
     374 */
     375function edge_suite_shortcode_edge_animation( $atts ) {
     376  $id = -1;
     377  extract( shortcode_atts( array(
     378    'id' => '-1',
     379    'left' => null,
     380    'top' => null,
     381  ), $atts ) );
     382
     383  $styles = '';
     384
     385  // Add left position offset to style.
     386  if(isset($left)){
     387    if($left == 'auto'){
     388      $styles .= 'margin: 0px auto;';
     389    }
     390    else if(intval($left) != 0){
     391      $styles .= 'margin-left:' . $left . 'px;';
     392    }
     393  }
     394
     395  //Add top position offset to style.
     396  if(isset($top) && intval($top) != 0){
     397    $styles .= 'margin-top:' . $top . 'px;';
     398  }
     399
     400  $definition_id = $id;
     401  $definition_res = edge_suite_comp_render($definition_id, $styles);
     402
     403  $stage = $scripts = '';
     404
     405  if($definition_res != NULL){
     406    // Todo: Placing scripts inline in the content really isn't pretty, but so far there
     407    // doesn't seem to be an easy way around this, otherwise we need to handle shortcode
     408    // before header fuctions get called.
     409    $scripts = implode("\n", $definition_res['scripts']);
     410
     411    $stage = $definition_res['stage'];
     412  }
     413
     414  return "\n" . $scripts . "\n" . $stage ."\n";
     415
     416}
     417add_shortcode('edge_animation', 'edge_suite_shortcode_edge_animation');
     418if(get_option('edge_suite_widget_shortcode') == 1){
     419  add_filter('widget_text', 'do_shortcode');
     420}
  • edge-suite/trunk/includes/edge-suite-comp.inc

    r602441 r608822  
    219219 *   Array with stage content and header scripts.
    220220 */
    221 function edge_suite_comp_render($definition_id) {
     221function edge_suite_comp_render($definition_id, $styles = '') {
    222222  $scripts = array();
    223223  $stage = '';
    224224  if ($definition_id > 0) {
    225 
    226225    $definition = edge_suite_comp_load_definition($definition_id);
     226
     227    if(!isset($definition->project_name)){
     228      return null;
     229    }
    227230
    228231    $edge_lib_path = EDGE_SUITE_PUBLIC_DIR_REL;
     
    258261
    259262    // Put everything together.
    260     $stage = '<div id="' . $div_id . '" style="' . $height . $width . '" class="' . $definition->composition_id . '">' . '</div>';
     263    $stage = '<div id="' . $div_id . '" style="' . $height . $width . $styles . '" class="' . $definition->composition_id . '">' . '</div>';
    261264
    262265  }
Note: See TracChangeset for help on using the changeset viewer.