Skip to content

Commit

Permalink
fixes #1834
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Mar 16, 2018
1 parent e8d908a commit 4e16632
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions docs/files/class-kirki-installer-section.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class Kirki_Installer_Section extends WP_Customize_Section {
*/
public $type = 'kirki_installer';

/**
* The plugin install URL.
*
* @access private
* @var string
*/
public $plugin_install_url;

/**
* Render the section.
*
Expand All @@ -55,15 +63,7 @@ protected function render() {
$installed = true;
}
}
// Get the plugin-installation URL.
$plugin_install_url = add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => 'kirki',
),
self_admin_url( 'update.php' )
);
$plugin_install_url = wp_nonce_url( $plugin_install_url, 'install-plugin_kirki' );
$plugin_install_url = $this->get_plugin_install_url();
$classes = 'cannot-expand accordion-section control-section control-section-themes control-section-' . $this->type;
?>
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>" style="border-top:none;border-bottom:1px solid #ddd;padding:7px 14px 16px 14px;text-align:right;">
Expand Down Expand Up @@ -105,7 +105,7 @@ protected function install_button() {
<p style="text-align:left;margin-top:0;">
<?php esc_attr_e( 'Please install the Kirki plugin to take full advantage of this theme\s customizer capabilities', 'textdomain' ); ?>
</p>
<a class="install-now button-primary button" data-slug="kirki" href="<?php echo esc_url_raw( $plugin_install_url ); ?>" aria-label="<?php esc_attr_e( 'Install Kirki Toolkit now', 'textdomain' ); ?>" data-name="Kirki Toolkit">
<a class="install-now button-primary button" data-slug="kirki" href="<?php echo esc_url_raw( $this->get_plugin_install_url() ); ?>" aria-label="<?php esc_attr_e( 'Install Kirki Toolkit now', 'textdomain' ); ?>" data-name="Kirki Toolkit">
<?php esc_html_e( 'Install Now', 'textdomain' ); ?>
</a>
<?php
Expand Down Expand Up @@ -169,6 +169,27 @@ protected function dismiss_button() {
</script>
<?php
}

/**
* Get the plugin install URL.
*
* @access private
* @return string
*/
private function get_plugin_install_url() {
if ( $this->plugin_install_url ) {
// Get the plugin-installation URL.
$this->plugin_install_url = add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => 'kirki',
),
self_admin_url( 'update.php' )
);
$this->plugin_install_url = wp_nonce_url( $plugin_install_url, 'install-plugin_kirki' );
}
return $this->plugin_install_url;
}
}
}

Expand Down

0 comments on commit 4e16632

Please sign in to comment.