PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 2.2
Vimeography: Vimeo Video Gallery WordPress Plugin v2.2
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / lib / rewrite.php

rewrite.php in Vimeography: Vimeo Video Gallery WordPress Plugin 2.2, at lib/rewrite.php

73 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 class Vimeography_Rewrite {
7
8 public function __construct() {
9 add_filter( 'query_vars', array($this, 'add_query_vars') );
10 add_action( 'generate_rewrite_rules', array($this, 'add_rewrite_rules' ) );
11 add_action( 'parse_request', array($this, 'parse_request') );
12 add_action( 'init', array( $this, 'flush_rewrite_rules' ) );
13 }
14
15 /**
16 * Flush rewrite rules on init if our rules are not yet included/registered.
17 *
18 * @return void
19 */
20 public function flush_rewrite_rules() {
21 $rules = get_site_option( 'rewrite_rules' );
22
23 if ( ! isset( $rules['(.?.+?)(?:/([0-9]+))?/#vimeography/(.+)$'] ) ) {
24 global $wp_rewrite;
25 $wp_rewrite->flush_rules();
26 }
27 }
28
29 /**
30 * [add_query_vars description]
31 * @param [type] $vars [description]
32 * @return [type] [description]
33 */
34 public function add_query_vars($vars) {
35 $vars[] = 'vimeography_action';
36 $vars[] = 'vimeography_gallery_id';
37 $vars[] = 'vimeography_request';
38 return $vars;
39 }
40
41 /**
42 * Adds custom rewrite rules.
43 * @param [type] $wp_rewrite [description]
44 * @return [type] [description]
45 */
46 public function add_rewrite_rules($wp_rewrite) {
47 $wp_rewrite->rules = array(
48 'vimeography/([0-9]{1,4})+/refresh\/?' => $wp_rewrite->index . '?vimeography_action=refresh&vimeography_gallery_id=' . $wp_rewrite->preg_index( 1 ),
49 '(.?.+?)(?:/([0-9]+))?/#vimeography/(.+)$' => $wp_rewrite->index . '?pagename=' . $wp_rewrite->preg_index( 1 ) . '&page=' . $wp_rewrite->preg_index( 2 ) . '&vimeography_request=' . $wp_rewrite->preg_index( 3 ),
50 '([^/]+)(?:/([0-9]+))?/#vimeography/(.+)$' => $wp_rewrite->index . '?name=' . $wp_rewrite->preg_index( 1 ) . '&page=' . $wp_rewrite->preg_index( 2 ) . '&vimeography_request=' . $wp_rewrite->preg_index( 3 ),
51 //'vimeography/notify\/?' => $wp_rewrite->index . '?vimeography_action=' . $wp_rewrite->preg_index( 1 ),
52 ) + $wp_rewrite->rules;
53 }
54
55 /**
56 * [parse_request description]
57 * @param [type] $wp [description]
58 * @return [type] [description]
59 */
60 public function parse_request($wp) {
61 if ( array_key_exists('vimeography_action', $wp->query_vars) && $wp->query_vars['vimeography_action'] == 'refresh' ) {
62 require_once VIMEOGRAPHY_PATH . 'lib/cache.php';
63 $cache = new Vimeography_Cache( $wp->query_vars['vimeography_gallery_id'] );
64
65 if ( $cache->exists() ) {
66 $cache->delete();
67 }
68
69 die('Thanks, Vimeo. Cache busted.');
70 }
71 }
72
73 }