├── .gitattributes
├── .gitignore
├── README.md
├── beaver-responsive-fonts.css.php
├── beaver-responsive-fonts.php
└── updater.php
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Beaver Responsive Fonts
2 |
3 | # PROOF OF CONCEPT ONLY
4 |
5 | Beaver Responsive Fonts is a plugin which adds a panel to the Theme customizer which lets you select a minimum and then a maximum font size and then the remaining headings are all scaled based on a perfect ratio value.
6 |
7 | ## DOWNLOAD
8 | https://github.com/jatacid/beaver-responsive-fonts/archive/master.zip
9 |
10 | #### Note
11 | Uses !important declarations and may override other styling that you have. Best to use on a new site so you can control the correct styling easier.
12 |
--------------------------------------------------------------------------------
/beaver-responsive-fonts.css.php:
--------------------------------------------------------------------------------
1 | /* ###########Small and up########## */
2 | html {font-size: px !important;} /* minimum font size*/
3 | h1 {
4 | font-size: rem !important;
5 | line-height: calc(rem * 1.5) !important;
6 | }
7 | h2 {font-size: rem !important;
8 | line-height: calc(rem * 1.4) !important;
9 | }
10 | h3 {font-size: rem !important;
11 | line-height: calc(rem * 1.3) !important;
12 | }
13 | h4 {font-size: rem !important;
14 | line-height: calc(rem * 1.4) !important;
15 | }
16 | h5 {font-size: rem !important;
17 | line-height: calc(rem * 1.4) !important;
18 | }
19 | h6 {font-size: rem !important;
20 | line-height: calc(rem * 1.4) !important;
21 | }
22 | p {font-size: rem !important;
23 | line-height: calc(rem * 1.4) !important;
24 | }
25 |
26 | /* ###########Medium and up########### */
27 | @media screen and (min-width: 768px){
28 | html {font-size: 2.0vw !important;}
29 | /* ###########Large and Up########### */
30 | @media screen and (min-width: 992px){
31 | html {font-size: 1.6vw !important;}
32 | }/* ##########Super Large And Up ############ */
33 | @media screen and (min-width: 1400px){
34 | html {font-size: px !important;}
35 | }
--------------------------------------------------------------------------------
/beaver-responsive-fonts.php:
--------------------------------------------------------------------------------
1 | plugin_basename( __FILE__ ),
43 | 'proper_folder_name' => 'beaver-responsive-fonts',
44 | 'api_url' => 'https://api.github.com/repos/' . $login,
45 | 'raw_url' => 'https://raw.github.com/' . $login .'/master',
46 | 'github_url' => 'https://github.com/'. $login,
47 | 'zip_url' => 'https://github.com/'. $login .'/archive/master.zip',
48 | 'sslverify' => true,
49 | 'requires' => '3.0',
50 | 'tested' => '3.3',
51 | 'readme' => 'README.md',
52 | 'access_token' => '',
53 | );
54 | new WP_GitHub_Updater( $config );
55 | }
56 | }
57 | add_action( 'init', 'responsive_fonts_updater' );
58 |
59 |
60 |
61 |
62 |
63 | function brf_change_customizer_defaults($wp_customize) {
64 |
65 | //checks for BB-theme
66 | $theme = wp_get_theme();
67 | if ('bb-theme' == $theme->name || 'Beaver Builder Theme' == $theme->parent_theme) {
68 |
69 | //$wp_customize->remove_section('fl-heading-font');
70 | //$wp_customize->remove_panel('fl-h1-font-size');
71 |
72 | $wp_customize->remove_control('fl-h1-font-size');
73 | $wp_customize->remove_control('fl-h2-font-size');
74 | $wp_customize->remove_control('fl-h3-font-size');
75 | $wp_customize->remove_control('fl-h4-font-size');
76 | $wp_customize->remove_control('fl-h5-font-size');
77 | $wp_customize->remove_control('fl-h6-font-size');
78 |
79 | $wp_customize->remove_control('fl-h1-line-height');
80 | $wp_customize->remove_control('fl-h2-line-height');
81 | $wp_customize->remove_control('fl-h3-line-height');
82 | $wp_customize->remove_control('fl-h4-line-height');
83 | $wp_customize->remove_control('fl-h5-line-height');
84 | $wp_customize->remove_control('fl-h6-line-height');
85 |
86 | // $wp_customize->remove_control('fl-h1-letter-spacing');
87 | // $wp_customize->remove_control('fl-h2-letter-spacing');
88 | // $wp_customize->remove_control('fl-h3-letter-spacing');
89 | // $wp_customize->remove_control('fl-h4-letter-spacing');
90 | // $wp_customize->remove_control('fl-h5-letter-spacing');
91 | // $wp_customize->remove_control('fl-h6-letter-spacing');
92 | }
93 |
94 | // $mods = FLCustomizer::get_mods();
95 | // $vars = array();
96 |
97 |
98 | // Set a Minimum option (mobiles)
99 | // Set a Maximum option (super desktops)
100 | // Set Ratio? Golden Ratio
101 |
102 |
103 | // Add the djcustom Media Settings to the customizer.
104 | $wp_customize->add_section( 'responsive-fonts', array(
105 | 'title'=> __( 'Responsive Typography Settings', 'fl-automator' ),
106 | 'description' => __( 'Overrides default Beaver Builder Typography with a more responsive equivalent.', 'fl-automator' ),
107 | 'priority'=> 130,
108 | ) );
109 |
110 | $wp_customize->add_setting('fl_responsive_font_minimum', array(
111 | 'default' => '14'
112 | )
113 | );
114 |
115 | $wp_customize->add_control('fl_responsive_font_minimum', array(
116 | 'label' => 'Responsive Minimum',
117 | 'description' => 'minimum paragraph font size (seen on mobiles)',
118 | 'section' => 'responsive-fonts',
119 | 'type' => 'number',
120 | 'input_attrs' => array(
121 | 'min' => 10,
122 | 'max' => 30),
123 | )
124 | );
125 |
126 |
127 | $wp_customize->add_setting('fl_responsive_font_maximum', array(
128 | 'default' => '20'
129 | )
130 | );
131 |
132 | $wp_customize->add_control('fl_responsive_font_maximum', array(
133 | 'label' => 'Responsive maximum',
134 | 'description' => 'maximum paragraph font size (seen on super desktops)',
135 | 'section' => 'responsive-fonts',
136 | 'type' => 'number',
137 | 'input_attrs' => array(
138 | 'min' => 10,
139 | 'max' => 30),
140 | )
141 | );
142 |
143 |
144 |
145 |
146 | $wp_customize->add_setting('fl_responsive_font_ratio', array(
147 | 'default' => 'option-1'
148 | )
149 | );
150 |
151 | $wp_customize->add_control('fl_responsive_font_ratio', array(
152 | 'label' => 'Ratio Type',
153 | 'description' => 'Select the ratio for font scaling',
154 | 'section' => 'responsive-fonts',
155 | 'type' => 'select',
156 | 'choices' => array(
157 | 'option-1' => 'Golden Ratio (Big & Beautiful)',
158 | 'option-2' => 'Perfect Fifth (Less dramatic)',
159 | 'option-3' => 'Perfect Fourth (Even Less Scaled)'),
160 | )
161 | );
162 |
163 | }
164 | add_action( 'customize_register', 'brf_change_customizer_defaults', 99);
165 |
166 |
167 |
168 |
169 |
170 | // Customize mce editor font sizes
171 | if ( ! function_exists( 'wpex_mce_text_sizes' ) ) {
172 | function wpex_mce_text_sizes( $initArray ){
173 | $initArray['fontsize_formats'] = "0.25rem 0.5rem 0.75rem 1rem 1.25rem 1.5rem 1.75rem 2rem 2.25rem 2.5rem 2.75rem 3rem 3.25rem 3.5rem 3.75rem 4rem 4.25rem 4.5rem 4.75rem 5rem 5.25rem 5.5rem 5.75rem 6rem 8rem";
174 | return $initArray;
175 | }
176 | }
177 | add_filter( 'tiny_mce_before_init', 'wpex_mce_text_sizes' );
178 |
179 |
180 |
181 |
182 |
183 | function beaver_responsive_fonts_do_css(){
184 |
185 | $settings = FLCustomizer::get_mods();
186 | $settings_min = $settings['fl_responsive_font_minimum'];
187 | if ($settings_min != false ){
188 | $settings_min = $settings_min;
189 | } else{
190 | $settings_min = '14';
191 | }
192 |
193 | $settings_max = $settings['fl_responsive_font_maximum'];
194 | if ($settings_max != false ){
195 | $settings_max = $settings_max;
196 | } else{
197 | $settings_max = '18';
198 | }
199 |
200 |
201 |
202 | $settings_ratio = $settings['fl_responsive_font_ratio'];
203 | if ($settings_ratio != false){
204 | $settings_ratio = $settings_ratio;
205 | } else{
206 | $settings_ratio = 'option-1';
207 | }
208 |
209 | if ($settings_ratio == 'option-1'){
210 | //Golden Ratio
211 | $settings_ratio = array(
212 | 'h1' => '4.236',
213 | 'h2' => '2.618',
214 | 'h3' => '1.618',
215 | 'h4' => '1.0',
216 | 'p' => '1.0',
217 | 'h5' => '0.618',
218 | 'h6' => '0.382',
219 | );
220 | } elseif ($settings_ratio == 'option-2') {
221 | //Perfect Fifth Ratio
222 | $settings_ratio = array(
223 | 'h1' => '3.375',
224 | 'h2' => '2.25',
225 | 'h3' => '1.5',
226 | 'h4' => '1.0',
227 | 'p' => '1.0',
228 | 'h5' => '0.667',
229 | 'h6' => '0.444',
230 |
231 | );
232 | }else {
233 | //Perfect Fourth Ratio
234 | $settings_ratio = array(
235 | 'h1' => '2.369',
236 | 'h2' => '1.777',
237 | 'h3' => '1.333',
238 | 'h4' => '1.0',
239 | 'p' => '1.0',
240 | 'h5' => '0.75',
241 | 'h6' => '0.563',
242 | );
243 | }
244 |
245 |
246 | echo '';
249 | }
250 | add_action('fl_head', 'beaver_responsive_fonts_do_css', 99);
--------------------------------------------------------------------------------
/updater.php:
--------------------------------------------------------------------------------
1 |
12 | * @link http://jkudish.com
13 | * @package WP_GitHub_Updater
14 | * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
15 | * @copyright Copyright (c) 2011-2013, Joachim Kudish
16 | *
17 | * GNU General Public License, Free Software Foundation
18 | *
19 | *
20 | * This program is free software; you can redistribute it and/or modify
21 | * it under the terms of the GNU General Public License as published by
22 | * the Free Software Foundation; either version 2 of the License, or
23 | * (at your option) any later version.
24 | *
25 | * This program is distributed in the hope that it will be useful,
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 | * GNU General Public License for more details.
29 | *
30 | * You should have received a copy of the GNU General Public License
31 | * along with this program; if not, write to the Free Software
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 | */
34 | class WP_GitHub_Updater {
35 |
36 | /**
37 | * GitHub Updater version
38 | */
39 | const VERSION = 1.6;
40 |
41 | /**
42 | * @var $config the config for the updater
43 | * @access public
44 | */
45 | var $config;
46 |
47 | /**
48 | * @var $missing_config any config that is missing from the initialization of this instance
49 | * @access public
50 | */
51 | var $missing_config;
52 |
53 | /**
54 | * @var $github_data temporiraly store the data fetched from GitHub, allows us to only load the data once per class instance
55 | * @access private
56 | */
57 | private $github_data;
58 |
59 |
60 | /**
61 | * Class Constructor
62 | *
63 | * @since 1.0
64 | * @param array $config the configuration required for the updater to work
65 | * @see has_minimum_config()
66 | * @return void
67 | */
68 | public function __construct( $config = array() ) {
69 |
70 | $defaults = array(
71 | 'slug' => plugin_basename( __FILE__ ),
72 | 'proper_folder_name' => dirname( plugin_basename( __FILE__ ) ),
73 | 'sslverify' => true,
74 | 'access_token' => '',
75 | );
76 |
77 | $this->config = wp_parse_args( $config, $defaults );
78 |
79 | // if the minimum config isn't set, issue a warning and bail
80 | if ( ! $this->has_minimum_config() ) {
81 | $message = 'The GitHub Updater was initialized without the minimum required configuration, please check the config in your plugin. The following params are missing: ';
82 | $message .= implode( ',', $this->missing_config );
83 | _doing_it_wrong( __CLASS__, $message , self::VERSION );
84 | return;
85 | }
86 |
87 | $this->set_defaults();
88 |
89 | add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) );
90 |
91 | // Hook into the plugin details screen
92 | add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 10, 3 );
93 | add_filter( 'upgrader_post_install', array( $this, 'upgrader_post_install' ), 10, 3 );
94 |
95 | // set timeout
96 | add_filter( 'http_request_timeout', array( $this, 'http_request_timeout' ) );
97 |
98 | // set sslverify for zip download
99 | add_filter( 'http_request_args', array( $this, 'http_request_sslverify' ), 10, 2 );
100 | }
101 |
102 | public function has_minimum_config() {
103 |
104 | $this->missing_config = array();
105 |
106 | $required_config_params = array(
107 | 'api_url',
108 | 'raw_url',
109 | 'github_url',
110 | 'zip_url',
111 | 'requires',
112 | 'tested',
113 | 'readme',
114 | );
115 |
116 | foreach ( $required_config_params as $required_param ) {
117 | if ( empty( $this->config[$required_param] ) )
118 | $this->missing_config[] = $required_param;
119 | }
120 |
121 | return ( empty( $this->missing_config ) );
122 | }
123 |
124 |
125 | /**
126 | * Check wether or not the transients need to be overruled and API needs to be called for every single page load
127 | *
128 | * @return bool overrule or not
129 | */
130 | public function overrule_transients() {
131 | return ( defined( 'WP_GITHUB_FORCE_UPDATE' ) && WP_GITHUB_FORCE_UPDATE );
132 | }
133 |
134 |
135 | /**
136 | * Set defaults
137 | *
138 | * @since 1.2
139 | * @return void
140 | */
141 | public function set_defaults() {
142 | if ( !empty( $this->config['access_token'] ) ) {
143 |
144 | // See Downloading a zipball (private repo) https://help.github.com/articles/downloading-files-from-the-command-line
145 | extract( parse_url( $this->config['zip_url'] ) ); // $scheme, $host, $path
146 |
147 | $zip_url = $scheme . '://api.github.com/repos' . $path;
148 | $zip_url = add_query_arg( array( 'access_token' => $this->config['access_token'] ), $zip_url );
149 |
150 | $this->config['zip_url'] = $zip_url;
151 | }
152 |
153 |
154 | if ( ! isset( $this->config['new_version'] ) )
155 | $this->config['new_version'] = $this->get_new_version();
156 |
157 | if ( ! isset( $this->config['last_updated'] ) )
158 | $this->config['last_updated'] = $this->get_date();
159 |
160 | if ( ! isset( $this->config['description'] ) )
161 | $this->config['description'] = $this->get_description();
162 |
163 | $plugin_data = $this->get_plugin_data();
164 | if ( ! isset( $this->config['plugin_name'] ) )
165 | $this->config['plugin_name'] = $plugin_data['Name'];
166 |
167 | if ( ! isset( $this->config['version'] ) )
168 | $this->config['version'] = $plugin_data['Version'];
169 |
170 | if ( ! isset( $this->config['author'] ) )
171 | $this->config['author'] = $plugin_data['Author'];
172 |
173 | if ( ! isset( $this->config['homepage'] ) )
174 | $this->config['homepage'] = $plugin_data['PluginURI'];
175 |
176 | if ( ! isset( $this->config['readme'] ) )
177 | $this->config['readme'] = 'README.md';
178 |
179 | }
180 |
181 |
182 | /**
183 | * Callback fn for the http_request_timeout filter
184 | *
185 | * @since 1.0
186 | * @return int timeout value
187 | */
188 | public function http_request_timeout() {
189 | return 2;
190 | }
191 |
192 | /**
193 | * Callback fn for the http_request_args filter
194 | *
195 | * @param unknown $args
196 | * @param unknown $url
197 | *
198 | * @return mixed
199 | */
200 | public function http_request_sslverify( $args, $url ) {
201 | if ( $this->config[ 'zip_url' ] == $url )
202 | $args[ 'sslverify' ] = $this->config[ 'sslverify' ];
203 |
204 | return $args;
205 | }
206 |
207 |
208 | /**
209 | * Get New Version from GitHub
210 | *
211 | * @since 1.0
212 | * @return int $version the version number
213 | */
214 | public function get_new_version() {
215 | $version = get_site_transient( md5($this->config['slug']).'_new_version' );
216 |
217 | if ( $this->overrule_transients() || ( !isset( $version ) || !$version || '' == $version ) ) {
218 |
219 | $raw_response = $this->remote_get( trailingslashit( $this->config['raw_url'] ) . basename( $this->config['slug'] ) );
220 |
221 | if ( is_wp_error( $raw_response ) )
222 | $version = false;
223 |
224 | if (is_array($raw_response)) {
225 | if (!empty($raw_response['body']))
226 | preg_match( '/.*Version\:\s*(.*)$/mi', $raw_response['body'], $matches );
227 | }
228 |
229 | if ( empty( $matches[1] ) )
230 | $version = false;
231 | else
232 | $version = $matches[1];
233 |
234 | // back compat for older readme version handling
235 | // only done when there is no version found in file name
236 | if ( false === $version ) {
237 | $raw_response = $this->remote_get( trailingslashit( $this->config['raw_url'] ) . $this->config['readme'] );
238 |
239 | if ( is_wp_error( $raw_response ) )
240 | return $version;
241 |
242 | preg_match( '#^\s*`*~Current Version\:\s*([^~]*)~#im', $raw_response['body'], $__version );
243 |
244 | if ( isset( $__version[1] ) ) {
245 | $version_readme = $__version[1];
246 | if ( -1 == version_compare( $version, $version_readme ) )
247 | $version = $version_readme;
248 | }
249 | }
250 |
251 | // refresh every 6 hours
252 | if ( false !== $version )
253 | set_site_transient( md5($this->config['slug']).'_new_version', $version, 60*60*6 );
254 | }
255 |
256 | return $version;
257 | }
258 |
259 |
260 | /**
261 | * Interact with GitHub
262 | *
263 | * @param string $query
264 | *
265 | * @since 1.6
266 | * @return mixed
267 | */
268 | public function remote_get( $query ) {
269 | if ( ! empty( $this->config['access_token'] ) )
270 | $query = add_query_arg( array( 'access_token' => $this->config['access_token'] ), $query );
271 |
272 | $raw_response = wp_remote_get( $query, array(
273 | 'sslverify' => $this->config['sslverify']
274 | ) );
275 |
276 | return $raw_response;
277 | }
278 |
279 |
280 | /**
281 | * Get GitHub Data from the specified repository
282 | *
283 | * @since 1.0
284 | * @return array $github_data the data
285 | */
286 | public function get_github_data() {
287 | if ( isset( $this->github_data ) && ! empty( $this->github_data ) ) {
288 | $github_data = $this->github_data;
289 | } else {
290 | $github_data = get_site_transient( md5($this->config['slug']).'_github_data' );
291 |
292 | if ( $this->overrule_transients() || ( ! isset( $github_data ) || ! $github_data || '' == $github_data ) ) {
293 | $github_data = $this->remote_get( $this->config['api_url'] );
294 |
295 | if ( is_wp_error( $github_data ) )
296 | return false;
297 |
298 | $github_data = json_decode( $github_data['body'] );
299 |
300 | // refresh every 6 hours
301 | set_site_transient( md5($this->config['slug']).'_github_data', $github_data, 60*60*6 );
302 | }
303 |
304 | // Store the data in this class instance for future calls
305 | $this->github_data = $github_data;
306 | }
307 |
308 | return $github_data;
309 | }
310 |
311 |
312 | /**
313 | * Get update date
314 | *
315 | * @since 1.0
316 | * @return string $date the date
317 | */
318 | public function get_date() {
319 | $_date = $this->get_github_data();
320 | return ( !empty( $_date->updated_at ) ) ? date( 'Y-m-d', strtotime( $_date->updated_at ) ) : false;
321 | }
322 |
323 |
324 | /**
325 | * Get plugin description
326 | *
327 | * @since 1.0
328 | * @return string $description the description
329 | */
330 | public function get_description() {
331 | $_description = $this->get_github_data();
332 | return ( !empty( $_description->description ) ) ? $_description->description : false;
333 | }
334 |
335 |
336 | /**
337 | * Get Plugin data
338 | *
339 | * @since 1.0
340 | * @return object $data the data
341 | */
342 | public function get_plugin_data() {
343 | include_once ABSPATH.'/wp-admin/includes/plugin.php';
344 | $data = get_plugin_data( WP_PLUGIN_DIR.'/'.$this->config['slug'] );
345 | return $data;
346 | }
347 |
348 |
349 | /**
350 | * Hook into the plugin update check and connect to GitHub
351 | *
352 | * @since 1.0
353 | * @param object $transient the plugin data transient
354 | * @return object $transient updated plugin data transient
355 | */
356 | public function api_check( $transient ) {
357 |
358 | // Check if the transient contains the 'checked' information
359 | // If not, just return its value without hacking it
360 | if ( empty( $transient->checked ) )
361 | return $transient;
362 |
363 | // check the version and decide if it's new
364 | $update = version_compare( $this->config['new_version'], $this->config['version'] );
365 |
366 | if ( 1 === $update ) {
367 | $response = new stdClass;
368 | $response->new_version = $this->config['new_version'];
369 | $response->slug = $this->config['proper_folder_name'];
370 | $response->url = add_query_arg( array( 'access_token' => $this->config['access_token'] ), $this->config['github_url'] );
371 | $response->package = $this->config['zip_url'];
372 |
373 | // If response is false, don't alter the transient
374 | if ( false !== $response )
375 | $transient->response[ $this->config['slug'] ] = $response;
376 | }
377 |
378 | return $transient;
379 | }
380 |
381 |
382 | /**
383 | * Get Plugin info
384 | *
385 | * @since 1.0
386 | * @param bool $false always false
387 | * @param string $action the API function being performed
388 | * @param object $args plugin arguments
389 | * @return object $response the plugin info
390 | */
391 | public function get_plugin_info( $false, $action, $response ) {
392 |
393 | // Check if this call API is for the right plugin
394 | if ( !isset( $response->slug ) || $response->slug != $this->config['slug'] )
395 | return false;
396 |
397 | $response->slug = $this->config['slug'];
398 | $response->plugin_name = $this->config['plugin_name'];
399 | $response->version = $this->config['new_version'];
400 | $response->author = $this->config['author'];
401 | $response->homepage = $this->config['homepage'];
402 | $response->requires = $this->config['requires'];
403 | $response->tested = $this->config['tested'];
404 | $response->downloaded = 0;
405 | $response->last_updated = $this->config['last_updated'];
406 | $response->sections = array( 'description' => $this->config['description'] );
407 | $response->download_link = $this->config['zip_url'];
408 |
409 | return $response;
410 | }
411 |
412 |
413 | /**
414 | * Upgrader/Updater
415 | * Move & activate the plugin, echo the update message
416 | *
417 | * @since 1.0
418 | * @param boolean $true always true
419 | * @param mixed $hook_extra not used
420 | * @param array $result the result of the move
421 | * @return array $result the result of the move
422 | */
423 | public function upgrader_post_install( $true, $hook_extra, $result ) {
424 |
425 | global $wp_filesystem;
426 |
427 | // Move & Activate
428 | $proper_destination = WP_PLUGIN_DIR.'/'.$this->config['proper_folder_name'];
429 | $wp_filesystem->move( $result['destination'], $proper_destination );
430 | $result['destination'] = $proper_destination;
431 | $activate = activate_plugin( WP_PLUGIN_DIR.'/'.$this->config['slug'] );
432 |
433 | // Output the update message
434 | $fail = __( 'The plugin has been updated, but could not be reactivated. Please reactivate it manually.', 'github_plugin_updater' );
435 | $success = __( 'Plugin reactivated successfully.', 'github_plugin_updater' );
436 | echo is_wp_error( $activate ) ? $fail : $success;
437 | return $result;
438 |
439 | }
440 | }
--------------------------------------------------------------------------------