11<?php
22/**
3- * Created by Alan on 15/7/2014.
3+ * Deprecated Pootlepress updater class
44 */
5-
6- if (!class_exists ('Pootlepress_Updater ' )) {
5+ if ( ! class_exists ( 'Pootlepress_Updater ' ) ) {
6+ /**
7+ * Updates pootlepress plugins
8+ * Created by Alan on 15/7/2014.
9+ * Class Pootlepress_Updater
10+ *********************************
11+ * Not supported since 2016-10-14
12+ *********************************
13+ */
714 class Pootlepress_Updater {
8- /**
9- * The plugin current version
10- * @var string
11- */
12- public $ current_version ;
13-
14- /**
15- * The plugin remote update path
16- * @var string
17- */
18- public $ update_path ;
19-
20- /**
21- * Plugin Slug (plugin_directory/plugin_file.php)
22- * @var string
23- */
24- public $ plugin_slug ;
25-
26- /**
27- * Plugin name (plugin_file)
28- * @var string
29- */
30- public $ slug ;
31-
32- /**
33- * Initialize a new instance of the WordPress Auto-Update class
34- * @param string $current_version
35- * @param string $update_path
36- * @param string $plugin_slug
37- */
38- function __construct ($ current_version , $ update_path , $ plugin_slug )
39- {
40- // Set the class public variables
41- $ this ->current_version = $ current_version ;
42- $ this ->update_path = $ update_path ;
43- $ this ->plugin_slug = $ plugin_slug ;
44- list ($ t1 , $ t2 ) = explode ('/ ' , $ plugin_slug );
45- $ this ->slug = $ t1 ;
46-
47- // define the alternative API for updating checking
48- add_filter ('pre_set_site_transient_update_plugins ' , array (&$ this , 'check_update ' ));
49-
50- // Define the alternative response for information checking
51- add_filter ('plugins_api ' , array (&$ this , 'check_info ' ), 10 , 3 );
52- }
53-
54- /**
55- * Add our self-hosted autoupdate plugin to the filter transient
56- *
57- * @param $transient
58- * @return object $ transient
59- */
60- public function check_update ($ transient )
61- {
62- if (isset ($ transient ->response [$ this ->plugin_slug ])) {
63- return $ transient ;
64- }
65-
66- // Get the remote version
67- $ remote_version = $ this ->getRemote_version ();
68-
69- // If a newer version is available, add the update
70- if (version_compare ($ this ->current_version , $ remote_version , '< ' )) {
71- $ obj = new stdClass ();
72- $ obj ->slug = $ this ->slug ;
73- $ obj ->new_version = $ remote_version ;
74- $ obj ->url = $ this ->update_path ;
75-
76- $ idx = strpos ($ this ->update_path , '? ' );
77- $ s = '? ' ;
78- if ($ idx !== false ) {
79- $ s = '& ' ;
80- } else {
81- $ s = '? ' ;
82- }
83- $ obj ->package = $ this ->update_path . $ s . "plugin= " . urlencode ($ this ->slug ); // this is the value that will be used to download package
84- $ transient ->response [$ this ->plugin_slug ] = $ obj ;
85- }
86- // var_dump($transient);
87- return $ transient ;
88- }
89-
90- /**
91- * Add our self-hosted description to the filter
92- *
93- * @param boolean $false
94- * @param array $action
95- * @param object $arg
96- * @return bool|object
97- */
98- public function check_info ($ false , $ action , $ arg )
99- {
100- if ($ arg ->slug === $ this ->slug ) {
101- $ information = $ this ->getRemote_information ();
102- return $ information ;
103- }
104- return $ false ;
105- }
106-
107- /**
108- * Return the remote version
109- * @return string $remote_version
110- */
111- public function getRemote_version ()
112- {
113- $ request = wp_remote_post ($ this ->update_path , array ('body ' => array ('action ' => 'version ' , 'plugin ' => $ this ->slug )));
114-
115- if (!is_wp_error ($ request ) || wp_remote_retrieve_response_code ($ request ) === 200 ) {
116- return $ request ['body ' ];
117- }
118- return false ;
119- }
120-
121-
122- /**
123- * Get information about the remote version
124- * @return bool|object
125- */
126- public function getRemote_information ()
127- {
128- $ request = wp_remote_post ($ this ->update_path , array ('body ' => array ('action ' => 'info ' , 'plugin ' => $ this ->slug )));
129- if (!is_wp_error ($ request ) || wp_remote_retrieve_response_code ($ request ) === 200 ) {
130- return unserialize ($ request ['body ' ]);
131- }
132- return false ;
133- }
134-
135- /**
136- * Return the status of the plugin licensing
137- * @return boolean $remote_license
138- */
139- public function getRemote_license ()
140- {
141- $ request = wp_remote_post ($ this ->update_path , array ('body ' => array ('action ' => 'license ' )));
142- if (!is_wp_error ($ request ) || wp_remote_retrieve_response_code ($ request ) === 200 ) {
143- return $ request ['body ' ];
144- }
145- return false ;
146- }
15+ function __construct () {}
14716 }
148- }
17+ }
0 commit comments