Plugin Directory

Changeset 612967


Ignore:
Timestamp:
10/15/2012 10:32:06 PM (13 years ago)
Author:
codeblab
Message:

Added the url for the featured image and some admin page code for it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • glass/trunk/glass.php

    r612275 r612967  
    5858      }
    5959
     60      /* Check if this page has a featured image and FeaturedImage is on. */
     61      if (has_post_thumbnail($post->ID)) {
     62    $featImage = $opt['myrtheGlassFeaturedImage'] or $featImage = 'n';
     63    if ($featImage == 'y') { return true; }
     64      }
     65
    6066      /* Check if category is allowed or not. */
    6167      if (is_category() || is_single()) {
     
    9096    }
    9197   
     98    function featuredImageURL()
     99    {
     100      if (function_exists('has_post_thumbnail')
     101       && has_post_thumbnail($post->ID)) {
     102    $fid = get_post_thumbnail_id($post->ID);
     103    $img = wp_get_attachment_image_src($fid, 'full');
     104        return $img[0];
     105      }
     106      return 'n';
     107    }
     108
    92109    /* Add all 'myrtheGlass' defaults to document for JavaScript usage. */
    93110    function addDefaults()
     
    101118    echo "\n";
    102119    echo "<script type='text/javascript'> // .oOXOo. Glass plugin.\n";
    103     foreach ($myrtheGlassOptions as $key => $value)
    104       if (substr($key, 0, 11) == 'myrtheGlass')
     120    foreach ($myrtheGlassOptions as $key => $value) {
     121      if (substr($key, 0, 11) == 'myrtheGlass') {
     122        if ($key == 'myrtheGlassFeaturedImage' && $value == 'y')
     123          $value = $this->featuredImageURL();  /* Sneeky replace. */
    105124        echo "  document.$key='$value';\n";
     125      }
     126    }
    106127    /* Add basename for image URLs. */
    107128    $url = get_settings('home')
     
    137158    'myrtheGlassCategories' => '',
    138159    'myrtheGlassOnFrontPage' => 'y',
     160    'myrtheGlassFeaturedImage' => 'n',
    139161    'myrtheGlassPages' => '',
    140162    'myrtheGlassExcludePlatforms' => 'iPod',
     
    176198      if (isset($_POST['update_MyrtheGlassSettings'])) {
    177199
    178     /* If OnFrontPage is not selected, it won't be in the $_POST. */
     200    /* If checkboxes are not selected they are not in the $_POST. */
    179201    $myrtheGlassOptions['myrtheGlassOnFrontPage'] = 'n';
     202    $myrtheGlassOptions['myrtheGlassFeaturedImage'] = 'n';
    180203
    181204    /*  Update all the updatables from $_POST to own array. */
     
    400423      echo "</td>\n";
    401424
     425      /* Featured Image, yes or no? */
     426      $key     = "myrtheGlassFeaturedImage";
     427      $val     = $myrtheGlassOptions[$key];
     428      $expl    = "Activate Glass for the Featured Image";
     429      $name    = preg_replace('/([A-Z])/', ' $1',$key);
     430      $name    = preg_replace('/myrthe /', '',$name);
     431
     432      echo "<tr><td>";
     433      echo "<input type='checkbox' name='$key' id='$key' value='y'";
     434      if ($val == 'y') { echo " checked='checked'"; }
     435      echo " /> $name";
     436      echo "</td><td>";
     437      echo "<label for='key'>";
     438      echo "$expl";
     439      echo "</label>";
     440      echo "</td>\n";
     441
    402442      /* Maybe use only specified categories. */
    403443      $key     = "myrtheGlassCategories";
Note: See TracChangeset for help on using the changeset viewer.