Plugin Directory

Changeset 1145869


Ignore:
Timestamp:
04/26/2015 02:33:40 AM (11 years ago)
Author:
slogsdon
Message:

add hooks. v1.5.0

Location:
staticwp/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • staticwp/trunk/README.md

    r1145758 r1145869  
    1111Upload the StaticWP plugin to your site, and activate it! Yep, that's it!
    1212
     13Optionally, you can set your web server to look in the storage directory (default is `staticwp/_site/`
     14in your uploads directory) for files prior to letting Wordpress take over control.
     15
     16## Hooks
     17
     18Need to modify how StaticWP works? Look to an action or a filter to accomplish what you need.
     19
     20### Actions
     21
     22#### `staticwp_pre_cache_hit`
     23
     24Called prior to outputting a cache hit to the client.
     25
     26Params:
     27
     28- `$_SERVER['REQUEST_URI']` - `string|null`
     29
     30#### `staticwp_post_cache_hit`
     31
     32Called after outputting a cache hit to the client.
     33
     34Params:
     35
     36- `$_SERVER['REQUEST_URI']` - `string|null`
     37
     38#### `staticwp_cache_miss`
     39
     40Called when a requested post does not exist in the cache.
     41
     42Params:
     43
     44- `$_SERVER['REQUEST_URI']` - `string|null`
     45
     46#### `staticwp_pre_cache_update`
     47
     48Called prior to saving a post's static HTML to disk.
     49
     50Params:
     51
     52- `$post_id` - `integer`
     53
     54#### `staticwp_post_cache_update`
     55
     56Called after saving a post's static HTML to disk.
     57
     58Params:
     59
     60- `$post_id` - `integer`
     61
     62### Filters
     63
     64#### `staticwp_preload_post_types`
     65
     66Allows a developer to modify the list of post types to preload.
     67Default/starting value is `array('post', 'page')`.
     68
     69Params:
     70
     71- `$post_types` - `array(string)`
     72
     73#### `staticwp_preload_{$post_type}_posts`
     74
     75Allows a developer to modify the list of posts to preload. By
     76default, all published posts of type `$post_type` will be used
     77and will be ordered by `post_date` in descending order.
     78
     79Params:
     80
     81- `$post_ids` - `array(integer)`
     82
     83#### `staticwp_cache_hit_contents`
     84
     85Allows a developer to modify the contents of a post's static
     86HTML prior to ouputting to the client.
     87
     88Params:
     89
     90- `$contents` - `string`
     91
     92#### `staticwp_cache_update_contents`
     93
     94Allows a developer to modify the contents of a post's static
     95HTML prior to saving to disk.
     96
     97Params:
     98
     99- `$contents` - `string`
     100- `$post_id` - `integer`
     101
     102#### `staticwp_cache_destination`
     103
     104Allows a developer to modify the storage directory for the static
     105HTML files.
     106
     107Params:
     108
     109- `$dir` - `string`
     110
    13111## Changelog
     112
     113### 1.5.0
     114
     115*Release Date - 25th April, 2015*
     116
     117- Add actions.
     118- Add filters.
     119- Fix bug with `StaticWP\StaticWP` not qualifying `Exception` before its use.
    14120
    15121### 1.4.2
    16122
    17 *In progress*
     123*Release Date - 25th April, 2015*
    18124
    19125- Fix issue with preload.
  • staticwp/trunk/includes/staticwp-admin.class.php

    r1145758 r1145869  
    183183                set_error_handler(array(__CLASS__, 'errorToException'), E_ALL);
    184184                try {
    185                     $types = array('post', 'page');
     185                    $types = apply_filters('staticwp_preload_post_types', array('post', 'page'));
    186186                    foreach ($types as $type) {
    187187                      $this->preload($type);
     
    300300
    301301        if ($query->have_posts()) {
    302             foreach ($query->posts as $post_id) {
     302            $posts = apply_filters('staticwp_preload_' . $post_type . '_posts', $query->posts);
     303            foreach ($posts as $post_id) {
    303304                $this->updateHtml($post_id);
    304305            }
  • staticwp/trunk/includes/staticwp.class.php

    r1145758 r1145869  
    22
    33namespace StaticWP;
     4
     5use \Exception;
    46
    57if (!defined('ABSPATH')) {
     
    8587        $file = $_SERVER['REQUEST_URI'] . 'index.html';
    8688        if (is_file($this->destination . $file)) {
    87             echo file_get_contents($this->destination . $file);
     89            $contents = file_get_contents($this->destination . $file);
     90            do_action('staticwp_pre_cache_hit', $_SERVER['REQUEST_URI']);
     91            echo apply_filters('staticwp_cache_hit_contents', $contents);
     92            do_action('staticwp_post_cache_hit', $_SERVER['REQUEST_URI']);
    8893            exit();
     94        } else {
     95            do_action('staticwp_cache_miss', $_SERVER['REQUEST_URI']);
    8996        }
    9097    }
     
    129136
    130137        curl_close($curl);
    131         file_put_contents($filename, $data);
     138        do_action('staticwp_pre_cache_update', $id);
     139        file_put_contents($filename, apply_filters('staticwp_cache_update_contents', $data, $id));
     140        do_action('staticwp_post_cache_update', $id);
    132141    }
    133142
     
    150159        }
    151160
    152         return $dir;
     161        return apply_filters('staticwp_cache_destination', $dir);
    153162    }
    154163}
  • staticwp/trunk/readme.txt

    r1109162 r1145869  
    1717Upload the StaticWP plugin to your site, and activate it! Yep, that's it!
    1818
     19Optionally, you can set your web server to look in the storage directory (default is `staticwp/_site/`
     20in your uploads directory) for files prior to letting Wordpress take over control.
     21
    1922== Changelog ==
    2023
     24= 1.5.0 =
     25*Release Date - 25th April, 2015*
     26
     27* Add actions.
     28* Add filters.
     29* Fix bug with `StaticWP\StaticWP` not qualifying `Exception` before its use.
     30
    2131= 1.4.2 =
    22 *In progress*
     32*Release Date - 25th April, 2015*
    2333
    2434* Fix issue with preload.
  • staticwp/trunk/staticwp.php

    r1145758 r1145869  
    44Description: Converts your blog into a static site.
    55Author: Shane Logsdon
    6 Version: 1.4.2
     6Version: 1.5.0
    77Author URI: http://www.slogsdon.com/
    88License: MIT
     
    1616
    1717if (!defined('STATICWP_VERSION')) {
    18     define('STATICWP_VERSION', '1.4.2');
     18    define('STATICWP_VERSION', '1.5.0');
    1919}
    2020
  • staticwp/trunk/templates/admin/info.page.php

    r1145758 r1145869  
    44  <nav>
    55    <?php \StaticWP\View::template('admin/menu', 'include'); ?>
     6    <br />
     7    <br />
    68  </nav>
    79 
  • staticwp/trunk/templates/admin/preload.page.php

    r1145758 r1145869  
    44  <nav>
    55    <?php \StaticWP\View::template('admin/menu', 'include'); ?>
     6    <br />
     7    <br />
    68  </nav>
    79
Note: See TracChangeset for help on using the changeset viewer.