| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
|
| 7 |
class Redux_Welcome { |
| 8 |
|
| 9 |
/** |
| 10 |
* @var string The capability users should have to view the page |
| 11 |
*/ |
| 12 |
public $minimum_capability = 'manage_options'; |
| 13 |
public $display_version = ""; |
| 14 |
public $redux_loaded = false; |
| 15 |
|
| 16 |
/** |
| 17 |
* Get things started |
| 18 |
* |
| 19 |
* @since 1.4 |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
|
| 23 |
add_action( 'redux/loaded', array( $this, 'init' ) ); |
| 24 |
|
| 25 |
add_action( 'wp_ajax_redux_support_hash', array( $this, 'support_hash' ) ); |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
public function init() { |
| 30 |
|
| 31 |
if ( $this->redux_loaded ) { |
| 32 |
return; |
| 33 |
} |
| 34 |
$this->redux_loaded = true; |
| 35 |
add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
| 36 |
|
| 37 |
if ( isset( $_GET['page'] ) ) { |
| 38 |
if ( substr( $_GET['page'], 0, 6 ) == "redux-" ) { |
| 39 |
$version = explode( '.', ReduxFramework::$_version ); |
| 40 |
$this->display_version = $version[0] . '.' . $version[1]; |
| 41 |
add_filter( 'admin_footer_text', array( $this, 'change_wp_footer' ) ); |
| 42 |
add_action( 'admin_head', array( $this, 'admin_head' ) ); |
| 43 |
} else { |
| 44 |
$this->check_version(); |
| 45 |
} |
| 46 |
} else { |
| 47 |
$this->check_version(); |
| 48 |
} |
| 49 |
update_option( 'redux_version_upgraded_from', ReduxFramework::$_version ); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
public function check_version() { |
| 54 |
global $pagenow; |
| 55 |
|
| 56 |
if ( $pagenow == "admin-ajax.php" || ( $GLOBALS['pagenow'] == "customize" && isset( $_GET['theme'] ) && ! empty( $_GET['theme'] ) ) ) { |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 60 |
$saveVer = Redux_Helpers::major_version( get_option( 'redux_version_upgraded_from' ) ); |
| 61 |
$curVer = Redux_Helpers::major_version( ReduxFramework::$_version ); |
| 62 |
$compare = false; |
| 63 |
|
| 64 |
if ( Redux_Helpers::isLocalHost() ) { |
| 65 |
$compare = true; |
| 66 |
} else if ( class_exists( 'ReduxFrameworkPlugin' ) ) { |
| 67 |
$compare = true; |
| 68 |
} else { |
| 69 |
$redux = ReduxFrameworkInstances::get_all_instances(); |
| 70 |
|
| 71 |
if ( is_array( $redux ) ) { |
| 72 |
foreach ( $redux as $panel ) { |
| 73 |
if ( $panel->args['dev_mode'] == 1 ) { |
| 74 |
$compare = true; |
| 75 |
break; |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
if ( $compare ) { |
| 82 |
$redirect = false; |
| 83 |
if ( empty( $saveVer ) ) { |
| 84 |
$redirect = true; // First time |
| 85 |
} |
| 86 |
// Removing redirect except for the first time with the plugin installed. :) Less annoying until we actually use this page. |
| 87 |
//else if ( version_compare( $curVer, $saveVer, '>' ) ) { |
| 88 |
// $redirect = true; // Previous version |
| 89 |
//} |
| 90 |
if ( $redirect && ! defined( 'WP_TESTS_DOMAIN' ) && ReduxFramework::$_as_plugin ) { |
| 91 |
add_action( 'init', array( $this, 'do_redirect' ) ); |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
public function do_redirect() { |
| 97 |
if ( ! defined( 'WP_CLI' ) ) { |
| 98 |
wp_redirect( admin_url( 'tools.php?page=redux-about' ) ); |
| 99 |
exit(); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
public function change_wp_footer() { |
| 104 |
echo __( 'If you like <strong>Redux</strong> please leave us a <a href="https://wordpress.org/support/view/plugin-reviews/redux-framework?filter=5#postform" target="_blank" class="redux-rating-link" data-rated="Thanks :)">★★★★★</a> rating. A huge thank you from Redux in advance!', 'redux-framework' ); |
| 105 |
} |
| 106 |
|
| 107 |
public function support_hash() { |
| 108 |
|
| 109 |
if ( ! wp_verify_nonce( $_POST['nonce'], 'redux-support-hash' ) ) { |
| 110 |
die(); |
| 111 |
} |
| 112 |
|
| 113 |
$data = get_option( 'redux_support_hash' ); |
| 114 |
$data = wp_parse_args( $data, array( 'check' => '', 'identifier' => '' ) ); |
| 115 |
$generate_hash = true; |
| 116 |
$system_info = Redux_Helpers::compileSystemStatus(); |
| 117 |
$newHash = md5( json_encode( $system_info ) ); |
| 118 |
$return = array(); |
| 119 |
if ( $newHash == $data['check'] ) { |
| 120 |
unset( $generate_hash ); |
| 121 |
} |
| 122 |
|
| 123 |
$post_data = array( |
| 124 |
'hash' => md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] ), |
| 125 |
'site' => esc_url( home_url( '/' ) ), |
| 126 |
'tracking' => Redux_Helpers::getTrackingObject(), |
| 127 |
'system_status' => $system_info, |
| 128 |
); |
| 129 |
//$post_data = json_encode( $post_data ); |
| 130 |
$post_data = serialize( $post_data ); |
| 131 |
|
| 132 |
if ( isset( $generate_hash ) && $generate_hash ) { |
| 133 |
|
| 134 |
$data['check'] = $newHash; |
| 135 |
$data['identifier'] = ""; |
| 136 |
$response = wp_remote_post( 'http://support.redux.io/v1/', array( |
| 137 |
'method' => 'POST', |
| 138 |
'timeout' => 65, |
| 139 |
'redirection' => 5, |
| 140 |
'httpversion' => '1.0', |
| 141 |
'blocking' => true, |
| 142 |
'compress' => true, |
| 143 |
'headers' => array(), |
| 144 |
'body' => array( |
| 145 |
'data' => $post_data, |
| 146 |
'serialize' => 1 |
| 147 |
) |
| 148 |
) |
| 149 |
); |
| 150 |
|
| 151 |
if ( is_wp_error( $response ) ) { |
| 152 |
echo json_encode( array( |
| 153 |
'status' => 'error', |
| 154 |
'message' => $response->get_error_message() |
| 155 |
) ); |
| 156 |
die( 1 ); |
| 157 |
} else { |
| 158 |
$response_code = wp_remote_retrieve_response_code( $response ); |
| 159 |
if ( $response_code == 200 ) { |
| 160 |
$response = wp_remote_retrieve_body( $response ); |
| 161 |
$return = json_decode( $response, true ); |
| 162 |
if ( isset( $return['identifier'] ) ) { |
| 163 |
$data['identifier'] = $return['identifier']; |
| 164 |
update_option( 'redux_support_hash', $data ); |
| 165 |
} |
| 166 |
} else { |
| 167 |
$response = wp_remote_retrieve_body( $response ); |
| 168 |
echo json_encode( array( |
| 169 |
'status' => 'error', |
| 170 |
'message' => $response |
| 171 |
) ); |
| 172 |
} |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
if ( ! empty( $data['identifier'] ) ) { |
| 177 |
$return['status'] = "success"; |
| 178 |
$return['identifier'] = $data['identifier']; |
| 179 |
} else { |
| 180 |
$return['status'] = "error"; |
| 181 |
$return['message'] = esc_html__( "Support hash could not be generated. Please try again later.", 'redux-framework' ); |
| 182 |
} |
| 183 |
|
| 184 |
echo json_encode( $return ); |
| 185 |
|
| 186 |
die( 1 ); |
| 187 |
} |
| 188 |
|
| 189 |
/** |
| 190 |
* Register the Dashboard Pages which are later hidden but these pages |
| 191 |
* are used to render the Welcome and Credits pages. |
| 192 |
* |
| 193 |
* @access public |
| 194 |
* @since 1.4 |
| 195 |
* @return void |
| 196 |
*/ |
| 197 |
public function admin_menus() { |
| 198 |
|
| 199 |
$page = 'add_management_page'; |
| 200 |
|
| 201 |
// About Page |
| 202 |
$page( |
| 203 |
esc_html__( 'Welcome to Redux Framework', 'redux-framework' ), esc_html__( 'Redux Framework', 'redux-framework' ), $this->minimum_capability, 'redux-about', array( |
| 204 |
$this, |
| 205 |
'about_screen' |
| 206 |
) |
| 207 |
); |
| 208 |
|
| 209 |
// Changelog Page |
| 210 |
$page( |
| 211 |
esc_html__( 'Redux Framework Changelog', 'redux-framework' ), esc_html__( 'Redux Framework Changelog', 'redux-framework' ), $this->minimum_capability, 'redux-changelog', array( |
| 212 |
$this, |
| 213 |
'changelog_screen' |
| 214 |
) |
| 215 |
); |
| 216 |
|
| 217 |
// Support Page |
| 218 |
$page( |
| 219 |
esc_html__( 'Get Support', 'redux-framework' ), esc_html__( 'Get Support', 'redux-framework' ), $this->minimum_capability, 'redux-support', array( |
| 220 |
$this, |
| 221 |
'get_support' |
| 222 |
) |
| 223 |
); |
| 224 |
|
| 225 |
// Support Page |
| 226 |
$page( |
| 227 |
esc_html__( 'Redux Extensions', 'redux-framework' ), esc_html__( 'Redux Extensions', 'redux-framework' ), $this->minimum_capability, 'redux-extensions', array( |
| 228 |
$this, |
| 229 |
'redux_extensions' |
| 230 |
) |
| 231 |
); |
| 232 |
|
| 233 |
|
| 234 |
// Credits Page |
| 235 |
$page( |
| 236 |
esc_html__( 'The people that develop Redux Framework', 'redux-framework' ), esc_html__( 'The people that develop Redux Framework', 'redux-framework' ), $this->minimum_capability, 'redux-credits', array( |
| 237 |
$this, |
| 238 |
'credits_screen' |
| 239 |
) |
| 240 |
); |
| 241 |
|
| 242 |
// Status Page |
| 243 |
$page( |
| 244 |
esc_html__( 'Redux Framework Status', 'redux-framework' ), esc_html__( 'Redux Framework Status', 'redux-framework' ), $this->minimum_capability, 'redux-status', array( |
| 245 |
$this, |
| 246 |
'status_screen' |
| 247 |
) |
| 248 |
); |
| 249 |
|
| 250 |
//remove_submenu_page( 'tools.php', 'redux-about' ); |
| 251 |
remove_submenu_page( 'tools.php', 'redux-status' ); |
| 252 |
remove_submenu_page( 'tools.php', 'redux-changelog' ); |
| 253 |
remove_submenu_page( 'tools.php', 'redux-getting-started' ); |
| 254 |
remove_submenu_page( 'tools.php', 'redux-credits' ); |
| 255 |
remove_submenu_page( 'tools.php', 'redux-support' ); |
| 256 |
remove_submenu_page( 'tools.php', 'redux-extensions' ); |
| 257 |
|
| 258 |
|
| 259 |
} |
| 260 |
|
| 261 |
/** |
| 262 |
* Hide Individual Dashboard Pages |
| 263 |
* |
| 264 |
* @access public |
| 265 |
* @since 1.4 |
| 266 |
* @return void |
| 267 |
*/ |
| 268 |
public function admin_head() { |
| 269 |
|
| 270 |
// Badge for welcome page |
| 271 |
//$badge_url = ReduxFramework::$_url . 'assets/images/redux-badge.png'; |
| 272 |
?> |
| 273 |
|
| 274 |
<script |
| 275 |
id="redux-qtip-js" |
| 276 |
src='<?php echo esc_url( ReduxFramework::$_url ); ?>assets/js/vendor/qtip/jquery.qtip.js'> |
| 277 |
</script> |
| 278 |
|
| 279 |
<script |
| 280 |
id="redux-welcome-admin-js" |
| 281 |
src='<?php echo esc_url( ReduxFramework::$_url ) ?>inc/welcome/js/redux-welcome-admin.js'> |
| 282 |
</script> |
| 283 |
|
| 284 |
<?php |
| 285 |
if ( isset ( $_GET['page'] ) && $_GET['page'] == "redux-support" ) : |
| 286 |
?> |
| 287 |
<script |
| 288 |
id="jquery-easing" |
| 289 |
src='<?php echo esc_url( ReduxFramework::$_url ); ?>inc/welcome/js/jquery.easing.min.js'> |
| 290 |
</script> |
| 291 |
<?php endif; ?> |
| 292 |
|
| 293 |
<link rel='stylesheet' id='redux-qtip-css' |
| 294 |
href='<?php echo esc_url( ReduxFramework::$_url ); ?>assets/css/vendor/qtip/jquery.qtip.css' |
| 295 |
type='text/css' media='all'/> |
| 296 |
|
| 297 |
<link rel='stylesheet' id='elusive-icons' |
| 298 |
href='<?php echo esc_url( ReduxFramework::$_url ); ?>assets/css/vendor/elusive-icons/elusive-icons.css' |
| 299 |
type='text/css' media='all'/> |
| 300 |
|
| 301 |
<link rel='stylesheet' id='redux-welcome-css' |
| 302 |
href='<?php echo esc_url( ReduxFramework::$_url ); ?>inc/welcome/css/redux-welcome.css' |
| 303 |
type='text/css' media='all'/> |
| 304 |
<style type="text/css"> |
| 305 |
.redux-badge:before { |
| 306 |
<?php echo is_rtl() ? 'right' : 'left'; ?> : 0; |
| 307 |
} |
| 308 |
|
| 309 |
.about-wrap .redux-badge { |
| 310 |
<?php echo is_rtl() ? 'left' : 'right'; ?> : 0; |
| 311 |
} |
| 312 |
|
| 313 |
.about-wrap .feature-rest div { |
| 314 |
padding- <?php echo is_rtl() ? 'left' : 'right'; ?>: 100px; |
| 315 |
} |
| 316 |
|
| 317 |
.about-wrap .feature-rest div.last-feature { |
| 318 |
padding- <?php echo is_rtl() ? 'right' : 'left'; ?>: 100px; |
| 319 |
padding- <?php echo is_rtl() ? 'left' : 'right'; ?>: 0; |
| 320 |
} |
| 321 |
|
| 322 |
.about-wrap .feature-rest div.icon:before { |
| 323 |
margin: <?php echo is_rtl() ? '0 -100px 0 0' : '0 0 0 -100px'; ?>; |
| 324 |
} |
| 325 |
</style> |
| 326 |
<?php |
| 327 |
} |
| 328 |
|
| 329 |
/** |
| 330 |
* Navigation tabs |
| 331 |
* |
| 332 |
* @access public |
| 333 |
* @since 1.9 |
| 334 |
* @return void |
| 335 |
*/ |
| 336 |
public function tabs() { |
| 337 |
$selected = isset ( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : 'redux-about'; |
| 338 |
$nonce = wp_create_nonce( 'redux-support-hash' ); |
| 339 |
?> |
| 340 |
<input type="hidden" id="redux_support_nonce" value="<?php echo esc_attr( $nonce ); ?>"/> |
| 341 |
<h2 class="nav-tab-wrapper"> |
| 342 |
<a class="nav-tab <?php echo $selected == 'redux-about' ? 'nav-tab-active' : ''; ?>" |
| 343 |
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-about' ), 'tools.php' ) ) ); ?>"> |
| 344 |
<?php esc_attr_e( "What's New", 'redux-framework' ); ?> |
| 345 |
</a> <a class="nav-tab <?php echo $selected == 'redux-extensions' ? 'nav-tab-active' : ''; ?>" |
| 346 |
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-extensions' ), 'tools.php' ) ) ); ?>"> |
| 347 |
<?php esc_attr_e( 'Extensions', 'redux-framework' ); ?> |
| 348 |
</a> <a class="nav-tab <?php echo $selected == 'redux-changelog' ? 'nav-tab-active' : ''; ?>" |
| 349 |
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-changelog' ), 'tools.php' ) ) ); ?>"> |
| 350 |
<?php esc_attr_e( 'Changelog', 'redux-framework' ); ?> |
| 351 |
</a> <a class="nav-tab <?php echo $selected == 'redux-credits' ? 'nav-tab-active' : ''; ?>" |
| 352 |
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-credits' ), 'tools.php' ) ) ); ?>"> |
| 353 |
<?php _e( 'Credits', 'redux-framework' ); ?> |
| 354 |
</a> <a class="nav-tab <?php echo $selected == 'redux-support' ? 'nav-tab-active' : ''; ?>" |
| 355 |
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-support' ), 'tools.php' ) ) ); ?>"> |
| 356 |
<?php esc_attr_e( 'Support', 'redux-framework' ); ?> |
| 357 |
</a> <a class="nav-tab <?php echo $selected == 'redux-status' ? 'nav-tab-active' : ''; ?>" |
| 358 |
href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-status' ), 'tools.php' ) ) ); ?>"> |
| 359 |
<?php esc_attr_e( 'Status', 'redux-framework' ); ?> |
| 360 |
</a> |
| 361 |
</h2> |
| 362 |
<?php |
| 363 |
} |
| 364 |
|
| 365 |
/** |
| 366 |
* Render About Screen |
| 367 |
* |
| 368 |
* @access public |
| 369 |
* @since 1.4 |
| 370 |
* @return void |
| 371 |
*/ |
| 372 |
public function about_screen() { |
| 373 |
// Stupid hack for Wordpress alerts and warnings |
| 374 |
echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 375 |
|
| 376 |
require_once 'views/about.php'; |
| 377 |
|
| 378 |
} |
| 379 |
|
| 380 |
/** |
| 381 |
* Render Changelog Screen |
| 382 |
* |
| 383 |
* @access public |
| 384 |
* @since 2.0.3 |
| 385 |
* @return void |
| 386 |
*/ |
| 387 |
public function changelog_screen() { |
| 388 |
// Stupid hack for Wordpress alerts and warnings |
| 389 |
echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 390 |
|
| 391 |
require_once 'views/changelog.php'; |
| 392 |
|
| 393 |
} |
| 394 |
|
| 395 |
/** |
| 396 |
* Render Changelog Screen |
| 397 |
* |
| 398 |
* @access public |
| 399 |
* @since 2.0.3 |
| 400 |
* @return void |
| 401 |
*/ |
| 402 |
public function redux_extensions() { |
| 403 |
// Stupid hack for Wordpress alerts and warnings |
| 404 |
echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 405 |
|
| 406 |
require_once 'views/extensions.php'; |
| 407 |
|
| 408 |
} |
| 409 |
|
| 410 |
|
| 411 |
/** |
| 412 |
* Render Get Support Screen |
| 413 |
* |
| 414 |
* @access public |
| 415 |
* @since 1.9 |
| 416 |
* @return void |
| 417 |
*/ |
| 418 |
public function get_support() { |
| 419 |
// Stupid hack for Wordpress alerts and warnings |
| 420 |
echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 421 |
|
| 422 |
require_once 'views/support.php'; |
| 423 |
|
| 424 |
} |
| 425 |
|
| 426 |
/** |
| 427 |
* Render Credits Screen |
| 428 |
* |
| 429 |
* @access public |
| 430 |
* @since 1.4 |
| 431 |
* @return void |
| 432 |
*/ |
| 433 |
public function credits_screen() { |
| 434 |
// Stupid hack for Wordpress alerts and warnings |
| 435 |
echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 436 |
|
| 437 |
require_once 'views/credits.php'; |
| 438 |
|
| 439 |
} |
| 440 |
|
| 441 |
/** |
| 442 |
* Render Status Report Screen |
| 443 |
* |
| 444 |
* @access public |
| 445 |
* @since 1.4 |
| 446 |
* @return void |
| 447 |
*/ |
| 448 |
public function status_screen() { |
| 449 |
// Stupid hack for Wordpress alerts and warnings |
| 450 |
echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 451 |
|
| 452 |
require_once 'views/status_report.php'; |
| 453 |
|
| 454 |
} |
| 455 |
|
| 456 |
/** |
| 457 |
* Parse the Redux readme.txt file |
| 458 |
* |
| 459 |
* @since 2.0.3 |
| 460 |
* @return string $readme HTML formatted readme file |
| 461 |
*/ |
| 462 |
public function parse_readme() { |
| 463 |
if ( file_exists( ReduxFramework::$_dir . 'inc/fields/raw/parsedown.php' ) ) { |
| 464 |
require_once ReduxFramework::$_dir . 'inc/fields/raw/parsedown.php'; |
| 465 |
$Parsedown = new Parsedown(); |
| 466 |
$data = @wp_remote_get( ReduxFramework::$_url . '../CHANGELOG.md' ); |
| 467 |
if ( isset( $data ) && ! empty( $data ) ) { |
| 468 |
$data = @wp_remote_retrieve_body( $data ); |
| 469 |
return $Parsedown->text( trim( str_replace( '# Redux Framework Changelog', '', $data ) ) ); |
| 470 |
} |
| 471 |
} |
| 472 |
|
| 473 |
return '<script src="' . 'http://gist-it.appspot.com/https://github.com/reduxframework/redux-framework/blob/master/CHANGELOG.md?slice=2:0&footer=0">// <![CDATA[// ]]></script>'; |
| 474 |
|
| 475 |
} |
| 476 |
|
| 477 |
public function actions() { |
| 478 |
?> |
| 479 |
<p class="redux-actions"> |
| 480 |
<a href="http://docs.reduxframework.com/" class="docs button button-primary">Docs</a> |
| 481 |
<a href="http://wordpress.org/plugins/redux-framework/" class="review-us button button-primary" |
| 482 |
target="_blank">Review Us</a> |
| 483 |
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MMFMHWUPKHKPW" |
| 484 |
class="review-us button button-primary" target="_blank">Donate</a> |
| 485 |
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://reduxframework.com" |
| 486 |
data-text="Reduce your dev time! Redux is the most powerful option framework for WordPress on the web" |
| 487 |
data-via="ReduxFramework" data-size="large" data-hashtags="Redux">Tweet</a> |
| 488 |
<script>!function( d, s, id ) { |
| 489 |
var js, fjs = d.getElementsByTagName( s )[0], p = /^http:/.test( d.location ) ? 'http' : 'https'; |
| 490 |
if ( !d.getElementById( id ) ) { |
| 491 |
js = d.createElement( s ); |
| 492 |
js.id = id; |
| 493 |
js.src = p + '://platform.twitter.com/widgets.js'; |
| 494 |
fjs.parentNode.insertBefore( js, fjs ); |
| 495 |
} |
| 496 |
}( document, 'script', 'twitter-wjs' );</script> |
| 497 |
</p> |
| 498 |
<?php |
| 499 |
} |
| 500 |
|
| 501 |
/** |
| 502 |
* Render Contributors List |
| 503 |
* |
| 504 |
* @since 1.4 |
| 505 |
* @uses Redux_Welcome::get_contributors() |
| 506 |
* @return string $contributor_list HTML formatted list of all the contributors for Redux |
| 507 |
*/ |
| 508 |
public function contributors() { |
| 509 |
$contributors = $this->get_contributors(); |
| 510 |
|
| 511 |
if ( empty ( $contributors ) ) { |
| 512 |
return ''; |
| 513 |
} |
| 514 |
|
| 515 |
$contributor_list = '<ul class="wp-people-group">'; |
| 516 |
|
| 517 |
foreach ( $contributors as $contributor ) { |
| 518 |
$contributor_list .= '<li class="wp-person">'; |
| 519 |
$contributor_list .= sprintf( '<a href="%s" title="%s" target="_blank">', esc_url( 'https://github.com/' . $contributor->login ), esc_html( sprintf( __( 'View %s', 'redux-framework' ), esc_html( $contributor->login ) ) ) |
| 520 |
); |
| 521 |
$contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ); |
| 522 |
$contributor_list .= '</a>'; |
| 523 |
$contributor_list .= sprintf( '<a class="web" href="%s" target="_blank">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) ); |
| 524 |
$contributor_list .= '</a>'; |
| 525 |
$contributor_list .= '</li>'; |
| 526 |
} |
| 527 |
|
| 528 |
$contributor_list .= '</ul>'; |
| 529 |
|
| 530 |
return $contributor_list; |
| 531 |
} |
| 532 |
|
| 533 |
/** |
| 534 |
* Retreive list of contributors from GitHub. |
| 535 |
* |
| 536 |
* @access public |
| 537 |
* @since 1.4 |
| 538 |
* @return array $contributors List of contributors |
| 539 |
*/ |
| 540 |
public function get_contributors() { |
| 541 |
$contributors = get_transient( 'redux_contributors' ); |
| 542 |
|
| 543 |
if ( false !== $contributors ) { |
| 544 |
return $contributors; |
| 545 |
} |
| 546 |
|
| 547 |
$response = wp_remote_get( 'https://api.github.com/repos/ReduxFramework/redux-framework/contributors', array( 'sslverify' => false ) ); |
| 548 |
|
| 549 |
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
| 550 |
return array(); |
| 551 |
} |
| 552 |
|
| 553 |
$contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
| 554 |
|
| 555 |
if ( ! is_array( $contributors ) ) { |
| 556 |
return array(); |
| 557 |
} |
| 558 |
|
| 559 |
set_transient( 'redux_contributors', $contributors, 3600 ); |
| 560 |
|
| 561 |
return $contributors; |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
new Redux_Welcome(); |
| 566 |
|
| 567 |
|