Plugin Directory

Changeset 1155546


Ignore:
Timestamp:
05/07/2015 05:10:41 PM (11 years ago)
Author:
DobsonDev
Message:

Tagging Version 1.1.3. Added transient caching for GitHub shortcodes and minified CSS and JS files.

Location:
dobsondev-shortcodes
Files:
12 added
2 deleted
3 edited
5 copied

Legend:

Unmodified
Added
Removed
  • dobsondev-shortcodes/tags/1.1.3/changelog.txt

    r1131367 r1155546  
    55* Added shortcode for displaying GitHub repository README.md files (1.1.0)
    66* Added shortcode for displaying GitHub repository file contents (1.1.1)
     7* Added Transient Cache support for the GitHub README and File shortcodes (1.1.3)
    78
    89Bug Fixes
     
    1213* Changed some documentation errors (1.1.1)
    1314* Fixed a return error in the GitHub README and GitHub File Contents shortcodes (1.1.2)
     15* Minified the CSS and JS scripts (1.1.3)
     16
    1417
    1518= 1.0 =
  • dobsondev-shortcodes/tags/1.1.3/dobsondev-shortcodes.php

    r1131367 r1155546  
    44 * Plugin URI: http://dobsondev.com/portfolio/dobsondev-shortcodes/
    55 * Description: A collection of helpful shortcodes.
    6  * Version: 1.1.2
     6 * Version: 1.1.3
    77 * Author: Alex Dobson
    88 * Author URI: http://dobsondev.com/
     
    2828/* Define our text domain for the plugin */
    2929define( 'DOBSONDEV_SHRTCODE_TEXTDOMAIN',  'dobsondev-shortcodes' );
     30/* Define our version number for the plugin */
     31define( 'DOBSONDEV_SHRTCODE_VER',  '1.1.2' );
     32
    3033
    3134/* Include Parsedown for Markdown Conversion */
     
    3538/* Enqueue the Style Sheet */
    3639function dobsondev_shrtcode_enqueue_scripts() {
    37   wp_enqueue_style( 'dobsondev-shortcodes', plugins_url( 'dobsondev-shortcodes.css' , __FILE__ ) );
     40  wp_enqueue_style( 'dobsondev-shortcodes', plugins_url( 'css/dobsondev-shortcodes.min.css' , __FILE__ ) );
    3841  wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
    39   wp_enqueue_script( 'dobsondev-shortcodes-js', plugins_url( 'dobsondev-shortcodes.js', __FILE__ ), array( 'jquery' ) );
     42  wp_enqueue_script( 'dobsondev-shortcodes-js', plugins_url( 'js/dobsondev-shortcodes.min.js', __FILE__ ), array( 'jquery' ) );
    4043}
    4144add_action( 'wp_enqueue_scripts', 'dobsondev_shrtcode_enqueue_scripts' );
     
    9295    'owner' => "NULL",
    9396    'repo' => "NULL",
     97    'cache_id' => "NULL",
    9498  ), $atts));
    9599  if ($owner == "NULL" || $repo == "NULL") {
    96100    return '<p> Please Enter a Owner and Repo for the embedGitHubReadme ShortCode. </p>';
    97101  } else {
    98     $curl = curl_init();
    99     curl_setopt_array($curl, array(
    100       CURLOPT_RETURNTRANSFER => 1,
    101       CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/readme',
    102       CURLOPT_USERAGENT => $repo,
    103       CURLOPT_HEADER => false
    104     ));
    105     $response = curl_exec($curl);
    106     // var_dump($response);
    107     $response_array = json_decode($response);
    108     // var_dump($response_array);
    109     $parsedown = new Parsedown();
    110     return $parsedown->text(base64_decode($response_array->content));
     102    // check to see if we have a cached transient stored
     103    if ( false === ( $readme_transient = get_transient( 'dobdev-t1-' . $cache_id ) ) ) {
     104      // we do not have a transient stored so we have to make the API call
     105      $curl = curl_init();
     106      curl_setopt_array($curl, array(
     107        CURLOPT_RETURNTRANSFER => 1,
     108        CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/readme',
     109        CURLOPT_USERAGENT => $repo,
     110        CURLOPT_HEADER => false
     111      ));
     112      $response = curl_exec($curl);
     113      // var_dump($response);
     114      $response_array = json_decode($response);
     115      // var_dump($response_array);
     116      $parsedown = new Parsedown();
     117      $output_readme = $parsedown->text(base64_decode($response_array->content));
     118      if ( $cache_id !== "NULL" ) {
     119        // set the transient so we can use it later for faster loading times
     120        // var_dump('DOBSONDEV T1 TRANSIENT SET | ID = ' . $cache_id);
     121        set_transient( 'dobdev-t1-' . $cache_id, $output_readme, DAY_IN_SECONDS );
     122      }
     123      return $output_readme;
     124    }
     125    // the transient was found so we will use it
     126    // var_dump('DOBSONDEV T1 TRANSIENT USED | ID = ' . $cache_id);
     127    return $readme_transient;
    111128  }
    112129}
     
    121138    'path' => "NULL",
    122139    'markdown' => "no",
     140    'cache_id' => "NULL",
    123141  ), $atts));
    124142  if ($owner == "NULL" || $repo == "NULL" || $path == "NULL") {
    125143    return '<p> Please Enter a Owner, Repo and Path for the embedGitHubReadme ShortCode. </p>';
    126144  } else {
    127     $curl = curl_init();
    128     curl_setopt_array($curl, array(
    129       CURLOPT_RETURNTRANSFER => 1,
    130       CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/contents/' . $path,
    131       CURLOPT_USERAGENT => $repo,
    132       CURLOPT_HEADER => false
    133     ));
    134     $response = curl_exec($curl);
    135     // var_dump($response);
    136     $response_array = json_decode($response);
    137     // var_dump($response_array);
    138     if (strcasecmp($markdown, "yes") == 0) {
    139       $parsedown = new Parsedown();
    140       return $parsedown->text(base64_decode($response_array->content));
    141     } else {
    142       return base64_decode($response_array->content);
     145    // check to see if we have a cached transient stored
     146    if ( false === ( $githubfile_transient = get_transient( 'dobdev-t2-' . $cache_id ) ) ) {
     147      // we do not have a transient stored so we have to make the API call
     148      $curl = curl_init();
     149      curl_setopt_array($curl, array(
     150        CURLOPT_RETURNTRANSFER => 1,
     151        CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/contents/' . $path,
     152        CURLOPT_USERAGENT => $repo,
     153        CURLOPT_HEADER => false
     154      ));
     155      $response = curl_exec($curl);
     156      // var_dump($response);
     157      $response_array = json_decode($response);
     158      // var_dump($response_array);
     159      if (strcasecmp($markdown, "yes") == 0) {
     160        $parsedown = new Parsedown();
     161        $output_md_file = $parsedown->text(base64_decode($response_array->content));
     162        if ( $cache_id !== "NULL" ) {
     163          // set the transient if the cache_id is set so we can use it later for faster loading time
     164          // var_dump('DOBSONDEV T2 TRANSIENT SET | ID = ' . $cache_id);
     165          set_transient( 'dobdev-t2-' . $cache_id, $output_md_file, DAY_IN_SECONDS );
     166        }
     167        return $output_md_file;
     168      } else {
     169        $output_file = base64_decode($response_array->content);
     170        if ( $cache_id !== "NULL" ) {
     171          // set the transient if the cache_id is set so we can use it later for faster loading time
     172          // var_dump('DOBSONDEV T2 TRANSIENT SET | ID = ' . $cache_id);
     173          set_transient( 'dobdev-t2-' . $cache_id, $output_file, DAY_IN_SECONDS );
     174        }
     175        return $output_file;
     176      }
    143177    }
     178    // the transient was found so we will use it
     179    // var_dump('DOBSONDEV T2 TRANSIENT USED | ID = ' . $cache_id);
     180    return $githubfile_transient;
    144181  }
    145182}
  • dobsondev-shortcodes/tags/1.1.3/readme.txt

    r1139363 r1155546  
    77Requires at least: 2.5
    88Tested up to: 4.2
    9 Stable tag: 1.1.2
     9Stable tag: 1.1.3
    1010
    1111Add a collection of helpful shortcodes to your site.
     
    4848**Embed GitHub Repo Readme**
    4949
    50 [embedGitHubReadme owner="Owner_of_Repo" repo="Repo_Name"]
     50[embedGitHubReadme owner="Owner_of_Repo" repo="Repo_Name" cache_id="id"]
    5151
    5252This shortcode will display the contents of any GitHub repository's README file. The markdown will displayed as HTML output onto the page. This shortcode uses GitHub API calls to ensure that as you update you README file the output from this shortcode will also update.
     
    5454The style will match that of your default page style, but if you want to change the style just wrap the shortcode inside of a div and then edit as much as the style as you want.
    5555
     56If you want to take advantage of WordPress' transient API for caching, simply enter an ID for the cache_id argument. Note that this ID can be anything other than "NULL", it doesn't necessarily have to be a number. Once entered this will cause the shortcode to cache the results of the API call for 24 hours. This means the shortcode will use those cached results and speed up the load times for 24 hours, at which point it will then call the API again to get any updates and use those cached results for another 24 hours.
     57
    5658**Embed GitHub Repo File Contents**
    5759
    58 [embedGitHubContent owner="Owner_of_Repo" repo="Repo_Name" path="Path_to_File" markdown="Yes/No"]
     60[embedGitHubContent owner="Owner_of_Repo" repo="Repo_Name" path="Path_to_File" markdown="Yes/No"  cache_id="id"]
    5961
    6062This shortcode will display the contents of a file from any GitHub repository. You must include the Owner of the repository, the repository name and the path to the file. Optionally, if the file is a markdown file you can put markdown="yes" and the plugin will output the markdown as HTML onto the page. If you give the shortcode a path to a folder rather than to a file it will output an array of the folders contents.
     63
     64If you want to take advantage of WordPress' transient API for caching, simply enter an ID for the cache_id argument. Note that this ID can be anything other than "NULL", it doesn't necessarily have to be a number. Once entered this will cause the shortcode to cache the results of the API call for 24 hours. This means the shortcode will use those cached results and speed up the load times for 24 hours, at which point it will then call the API again to get any updates and use those cached results for another 24 hours.
    6165
    6266**Embed Twitch Stream**
     
    153157* Added shortcode for displaying GitHub repository README.md files (1.1.0)
    154158* Added shortcode for displaying GitHub repository file contents (1.1.1)
     159* Added Transient Cache support for the GitHub README and File shortcodes (1.1.3)
    155160
    156161Bug Fixes
     
    160165* Changed some documentation errors (1.1.1)
    161166* Fixed a return error in the GitHub README and GitHub File Contents shortcodes (1.1.2)
     167* Minified the CSS and JS scripts (1.1.3)
    162168
    163169= - 1.0 - =
  • dobsondev-shortcodes/trunk/changelog.txt

    r1131367 r1155546  
    55* Added shortcode for displaying GitHub repository README.md files (1.1.0)
    66* Added shortcode for displaying GitHub repository file contents (1.1.1)
     7* Added Transient Cache support for the GitHub README and File shortcodes (1.1.3)
    78
    89Bug Fixes
     
    1213* Changed some documentation errors (1.1.1)
    1314* Fixed a return error in the GitHub README and GitHub File Contents shortcodes (1.1.2)
     15* Minified the CSS and JS scripts (1.1.3)
     16
    1417
    1518= 1.0 =
  • dobsondev-shortcodes/trunk/dobsondev-shortcodes.php

    r1131367 r1155546  
    44 * Plugin URI: http://dobsondev.com/portfolio/dobsondev-shortcodes/
    55 * Description: A collection of helpful shortcodes.
    6  * Version: 1.1.2
     6 * Version: 1.1.3
    77 * Author: Alex Dobson
    88 * Author URI: http://dobsondev.com/
     
    2828/* Define our text domain for the plugin */
    2929define( 'DOBSONDEV_SHRTCODE_TEXTDOMAIN',  'dobsondev-shortcodes' );
     30/* Define our version number for the plugin */
     31define( 'DOBSONDEV_SHRTCODE_VER',  '1.1.2' );
     32
    3033
    3134/* Include Parsedown for Markdown Conversion */
     
    3538/* Enqueue the Style Sheet */
    3639function dobsondev_shrtcode_enqueue_scripts() {
    37   wp_enqueue_style( 'dobsondev-shortcodes', plugins_url( 'dobsondev-shortcodes.css' , __FILE__ ) );
     40  wp_enqueue_style( 'dobsondev-shortcodes', plugins_url( 'css/dobsondev-shortcodes.min.css' , __FILE__ ) );
    3841  wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
    39   wp_enqueue_script( 'dobsondev-shortcodes-js', plugins_url( 'dobsondev-shortcodes.js', __FILE__ ), array( 'jquery' ) );
     42  wp_enqueue_script( 'dobsondev-shortcodes-js', plugins_url( 'js/dobsondev-shortcodes.min.js', __FILE__ ), array( 'jquery' ) );
    4043}
    4144add_action( 'wp_enqueue_scripts', 'dobsondev_shrtcode_enqueue_scripts' );
     
    9295    'owner' => "NULL",
    9396    'repo' => "NULL",
     97    'cache_id' => "NULL",
    9498  ), $atts));
    9599  if ($owner == "NULL" || $repo == "NULL") {
    96100    return '<p> Please Enter a Owner and Repo for the embedGitHubReadme ShortCode. </p>';
    97101  } else {
    98     $curl = curl_init();
    99     curl_setopt_array($curl, array(
    100       CURLOPT_RETURNTRANSFER => 1,
    101       CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/readme',
    102       CURLOPT_USERAGENT => $repo,
    103       CURLOPT_HEADER => false
    104     ));
    105     $response = curl_exec($curl);
    106     // var_dump($response);
    107     $response_array = json_decode($response);
    108     // var_dump($response_array);
    109     $parsedown = new Parsedown();
    110     return $parsedown->text(base64_decode($response_array->content));
     102    // check to see if we have a cached transient stored
     103    if ( false === ( $readme_transient = get_transient( 'dobdev-t1-' . $cache_id ) ) ) {
     104      // we do not have a transient stored so we have to make the API call
     105      $curl = curl_init();
     106      curl_setopt_array($curl, array(
     107        CURLOPT_RETURNTRANSFER => 1,
     108        CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/readme',
     109        CURLOPT_USERAGENT => $repo,
     110        CURLOPT_HEADER => false
     111      ));
     112      $response = curl_exec($curl);
     113      // var_dump($response);
     114      $response_array = json_decode($response);
     115      // var_dump($response_array);
     116      $parsedown = new Parsedown();
     117      $output_readme = $parsedown->text(base64_decode($response_array->content));
     118      if ( $cache_id !== "NULL" ) {
     119        // set the transient so we can use it later for faster loading times
     120        // var_dump('DOBSONDEV T1 TRANSIENT SET | ID = ' . $cache_id);
     121        set_transient( 'dobdev-t1-' . $cache_id, $output_readme, DAY_IN_SECONDS );
     122      }
     123      return $output_readme;
     124    }
     125    // the transient was found so we will use it
     126    // var_dump('DOBSONDEV T1 TRANSIENT USED | ID = ' . $cache_id);
     127    return $readme_transient;
    111128  }
    112129}
     
    121138    'path' => "NULL",
    122139    'markdown' => "no",
     140    'cache_id' => "NULL",
    123141  ), $atts));
    124142  if ($owner == "NULL" || $repo == "NULL" || $path == "NULL") {
    125143    return '<p> Please Enter a Owner, Repo and Path for the embedGitHubReadme ShortCode. </p>';
    126144  } else {
    127     $curl = curl_init();
    128     curl_setopt_array($curl, array(
    129       CURLOPT_RETURNTRANSFER => 1,
    130       CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/contents/' . $path,
    131       CURLOPT_USERAGENT => $repo,
    132       CURLOPT_HEADER => false
    133     ));
    134     $response = curl_exec($curl);
    135     // var_dump($response);
    136     $response_array = json_decode($response);
    137     // var_dump($response_array);
    138     if (strcasecmp($markdown, "yes") == 0) {
    139       $parsedown = new Parsedown();
    140       return $parsedown->text(base64_decode($response_array->content));
    141     } else {
    142       return base64_decode($response_array->content);
     145    // check to see if we have a cached transient stored
     146    if ( false === ( $githubfile_transient = get_transient( 'dobdev-t2-' . $cache_id ) ) ) {
     147      // we do not have a transient stored so we have to make the API call
     148      $curl = curl_init();
     149      curl_setopt_array($curl, array(
     150        CURLOPT_RETURNTRANSFER => 1,
     151        CURLOPT_URL => 'https://api.github.com/repos/' . $owner . '/' . $repo . '/contents/' . $path,
     152        CURLOPT_USERAGENT => $repo,
     153        CURLOPT_HEADER => false
     154      ));
     155      $response = curl_exec($curl);
     156      // var_dump($response);
     157      $response_array = json_decode($response);
     158      // var_dump($response_array);
     159      if (strcasecmp($markdown, "yes") == 0) {
     160        $parsedown = new Parsedown();
     161        $output_md_file = $parsedown->text(base64_decode($response_array->content));
     162        if ( $cache_id !== "NULL" ) {
     163          // set the transient if the cache_id is set so we can use it later for faster loading time
     164          // var_dump('DOBSONDEV T2 TRANSIENT SET | ID = ' . $cache_id);
     165          set_transient( 'dobdev-t2-' . $cache_id, $output_md_file, DAY_IN_SECONDS );
     166        }
     167        return $output_md_file;
     168      } else {
     169        $output_file = base64_decode($response_array->content);
     170        if ( $cache_id !== "NULL" ) {
     171          // set the transient if the cache_id is set so we can use it later for faster loading time
     172          // var_dump('DOBSONDEV T2 TRANSIENT SET | ID = ' . $cache_id);
     173          set_transient( 'dobdev-t2-' . $cache_id, $output_file, DAY_IN_SECONDS );
     174        }
     175        return $output_file;
     176      }
    143177    }
     178    // the transient was found so we will use it
     179    // var_dump('DOBSONDEV T2 TRANSIENT USED | ID = ' . $cache_id);
     180    return $githubfile_transient;
    144181  }
    145182}
  • dobsondev-shortcodes/trunk/readme.txt

    r1139363 r1155546  
    77Requires at least: 2.5
    88Tested up to: 4.2
    9 Stable tag: 1.1.2
     9Stable tag: 1.1.3
    1010
    1111Add a collection of helpful shortcodes to your site.
     
    4848**Embed GitHub Repo Readme**
    4949
    50 [embedGitHubReadme owner="Owner_of_Repo" repo="Repo_Name"]
     50[embedGitHubReadme owner="Owner_of_Repo" repo="Repo_Name" cache_id="id"]
    5151
    5252This shortcode will display the contents of any GitHub repository's README file. The markdown will displayed as HTML output onto the page. This shortcode uses GitHub API calls to ensure that as you update you README file the output from this shortcode will also update.
     
    5454The style will match that of your default page style, but if you want to change the style just wrap the shortcode inside of a div and then edit as much as the style as you want.
    5555
     56If you want to take advantage of WordPress' transient API for caching, simply enter an ID for the cache_id argument. Note that this ID can be anything other than "NULL", it doesn't necessarily have to be a number. Once entered this will cause the shortcode to cache the results of the API call for 24 hours. This means the shortcode will use those cached results and speed up the load times for 24 hours, at which point it will then call the API again to get any updates and use those cached results for another 24 hours.
     57
    5658**Embed GitHub Repo File Contents**
    5759
    58 [embedGitHubContent owner="Owner_of_Repo" repo="Repo_Name" path="Path_to_File" markdown="Yes/No"]
     60[embedGitHubContent owner="Owner_of_Repo" repo="Repo_Name" path="Path_to_File" markdown="Yes/No"  cache_id="id"]
    5961
    6062This shortcode will display the contents of a file from any GitHub repository. You must include the Owner of the repository, the repository name and the path to the file. Optionally, if the file is a markdown file you can put markdown="yes" and the plugin will output the markdown as HTML onto the page. If you give the shortcode a path to a folder rather than to a file it will output an array of the folders contents.
     63
     64If you want to take advantage of WordPress' transient API for caching, simply enter an ID for the cache_id argument. Note that this ID can be anything other than "NULL", it doesn't necessarily have to be a number. Once entered this will cause the shortcode to cache the results of the API call for 24 hours. This means the shortcode will use those cached results and speed up the load times for 24 hours, at which point it will then call the API again to get any updates and use those cached results for another 24 hours.
    6165
    6266**Embed Twitch Stream**
     
    153157* Added shortcode for displaying GitHub repository README.md files (1.1.0)
    154158* Added shortcode for displaying GitHub repository file contents (1.1.1)
     159* Added Transient Cache support for the GitHub README and File shortcodes (1.1.3)
    155160
    156161Bug Fixes
     
    160165* Changed some documentation errors (1.1.1)
    161166* Fixed a return error in the GitHub README and GitHub File Contents shortcodes (1.1.2)
     167* Minified the CSS and JS scripts (1.1.3)
    162168
    163169= - 1.0 - =
Note: See TracChangeset for help on using the changeset viewer.