slug ) ) { return; } $this->plugin_info = $this->call_plugin_api( $this->slug ); } /** * Call plugin API to get plugins info * * @param plugin-slug $slug The plugin slug. * * @return mixed */ private function call_plugin_api( $slug ) { if ( empty( $slug ) ) { return; } include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); $call_api = get_transient( 'ti_cust_notify_plugin_info_' . $slug ); if ( false === $call_api ) { $call_api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'downloaded' => false, 'rating' => false, 'description' => false, 'short_description' => true, 'donate_link' => false, 'tags' => false, 'sections' => false, 'homepage' => false, 'added' => false, 'last_updated' => false, 'compatibility' => false, 'tested' => false, 'requires' => false, 'downloadlink' => false, 'icons' => false, ), ) ); set_transient( 'ti_cust_notify_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); } return $call_api; } /** * Add custom parameters to pass to the JS via JSON. * * @since 1.0.0 * @access public * @return array */ public function json() { $json = parent::json(); $json['name'] = ! empty( $this->plugin_info ) && ! is_wp_error( $this->plugin_info ) && property_exists( $this->plugin_info, 'name' ) ? $this->plugin_info->name : ''; $json['description'] = $this->description; $json['plugin_install_button'] = $this->create_plugin_install_button( $this->slug, $this->options ); $json['hide_notice'] = $this->hide_notice; return $json; } /** * Outputs the structure for the customizer control * * @since 1.0.0 * @access public * @return void */ protected function render_template() { ?> <# if ( ! data.hide_notice ) { #>
  • <# if ( data.title ) { #>

    {{{ data.title }}}

    <# } #>
    <# if ( data.name ) { #>

    {{{data.name}}}

    <# } #> <# if( data.description ) { #>

    {{{ data.description }}}

    <# } #> <# if ( data.plugin_install_button ) { #> {{{data.plugin_install_button}}} <# } #>
  • <# } #>