is_plugin_active( $slug . '/' . $slug . '.php' ), 'needs' => $needs ); } return array( 'status' => false, 'needs' => 'install' ); } public function create_action_link( $state, $slug ) { switch ( $state ) { case 'install': return wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $slug ), network_admin_url( 'update.php' ) ), 'install-plugin_' . $slug ); break; case 'deactivate': return add_query_arg( array( 'action' => 'deactivate', 'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug . '/' . $slug . '.php' ), ), network_admin_url( 'plugins.php' ) ); break; case 'activate': return add_query_arg( array( 'action' => 'activate', 'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ), ), network_admin_url( 'plugins.php' ) ); break; } } /** * Add custom parameters to pass to the JS via JSON. * * @since 1.0.0 * @access public * @return void */ public function json() { $json = parent::json(); global $activello_required_actions; $formatted_array = array(); foreach ( $activello_required_actions as $key => $activello_required_action ) { if ( $activello_required_action['check'] ) { continue; } $activello_required_action['index'] = $key + 1; if ( isset($activello_required_action['plugin_slug']) ) { $active = $this->check_active( $activello_required_action['plugin_slug'] ); $activello_required_action['url'] = $this->create_action_link( $active['needs'], $activello_required_action['plugin_slug'] ); if ( $active['needs'] !== 'install' && $active['status'] ) { $activello_required_action['class'] = 'active'; }else{ $activello_required_action['class'] = ''; } switch ( $active['needs'] ) { case 'install': $activello_required_action['button_class'] = 'install-now button'; $activello_required_action['button_label'] = __( 'Install', 'activello' ); break; case 'activate': $activello_required_action['button_class'] = 'activate-now button button-primary'; $activello_required_action['button_label'] = __( 'Activate', 'activello' ); break; case 'deactivate': $activello_required_action['button_class'] = 'deactivate-now button'; $activello_required_action['button_label'] = __( 'Deactivate', 'activello' ); break; } } $formatted_array[] = $activello_required_action; } $json['required_actions'] = $formatted_array; $json['total_actions'] = count($activello_required_actions); $json['succes_text'] = $this->succes_text; $json['facebook'] = $this->facebook; $json['twitter'] = $this->twitter; $json['wp_review'] = $this->wp_review; if ( $this->wp_review ) { $json['theme_slug'] = get_template(); } return $json; } /** * Outputs the Underscore.js template. * * @since 1.0.0 * @access public * @return void */ protected function render_template() { ?>
{{ data.required_actions[action].title }}
<# if( data.facebook ){ #> Facebook <# } #> <# if( data.twitter ){ #> Twitter <# } #> <# if( data.wp_review ){ #> Review this theme on w.org <# } #>
<# }else{ #> <# } #>