is_plugin_active example

function wp_load_press_this() {
    $plugin_slug = 'press-this';
    $plugin_file = 'press-this/press-this-plugin.php';

    if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
        wp_die(
            __( 'Sorry, you are not allowed to create posts as this user.' ),
            __( 'You need a higher level of permission.' ),
            403
        );
    } elseif ( is_plugin_active( $plugin_file ) ) {
        include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
        $wp_press_this = new WP_Press_This_Plugin();
        $wp_press_this->html();
    } elseif ( current_user_can( 'activate_plugins' ) ) {
        if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
            $url    = wp_nonce_url(
                add_query_arg(
                    array(
                        'action' => 'activate',
                        'plugin' => $plugin_file,
                        'from'   => 'press-this',
                    ),
if ( ! is_null( $auto_update_forced ) ) {
                $plugin_data['auto-update-forced'] = $auto_update_forced;
            }

            $plugins['all'][ $plugin_file ] = $plugin_data;
            // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade.             if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
                $plugins['upgrade'][ $plugin_file ] = $plugin_data;
            }

            // Filter into individual sections.             if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
                if ( $show_network_active ) {
                    // On the non-network screen, show inactive network-only plugins if allowed.                     $plugins['inactive'][ $plugin_file ] = $plugin_data;
                } else {
                    // On the non-network screen, filter out network-only plugins as long as they're not individually active.                     unset( $plugins['all'][ $plugin_file ] );
                }
            } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
                if ( $show_network_active ) {
                    // On the non-network screen, show network-active plugins if allowed.                     $plugins['active'][ $plugin_file ] = $plugin_data;
                }
$wp_list_table = _get_list_table(
        'WP_Plugins_List_Table',
        array(
            'screen' => get_current_screen(),
        )
    );

    if ( is_network_admin() || ! is_multisite() ) {
        if ( is_network_admin() ) {
            $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
        } else {
            $active_class = is_plugin_active( $file ) ? ' active' : '';
        }

        $requires_php   = isset( $response->requires_php ) ? $response->requires_php : null;
        $compatible_php = is_php_version_compatible( $requires_php );
        $notice_type    = $compatible_php ? 'notice-warning' : 'notice-error';

        printf(
            '<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
            '<td colspan="%s" class="plugin-update colspanchange">' .
            '<div class="update-message notice inline %s notice-alt"><p>',
            $active_class,
            

        } else {
            $install_actions['plugins_page'] = sprintf(
                '<a href="%s" target="_parent">%s</a>',
                self_admin_url( 'plugins.php' ),
                __( 'Go to Plugins page' )
            );
        }

        if ( ! $this->result || is_wp_error( $this->result ) ) {
            unset( $install_actions['activate_plugin']$install_actions['network_activate'] );
        } elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) || is_plugin_active( $plugin_file ) ) {
            unset( $install_actions['activate_plugin'] );
        }

        /** * Filters the list of action links available following a single plugin installation. * * @since 2.7.0 * * @param string[] $install_actions Array of plugin action links. * @param object $api Object containing WordPress.org API plugin data. Empty * for non-API installs, such as when a plugin is installed * via upload. * @param string $plugin_file Path to the plugin file relative to the plugins directory. */
unset( $help );
}

require_once ABSPATH . 'wp-admin/admin-header.php';

// Also used by the Edit Tag form. require_once ABSPATH . 'wp-admin/includes/edit-tag-messages.php';

$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';

if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
    $import_link = admin_url( 'admin.php?import=wpcat2tag' );
} else {
    $import_link = admin_url( 'import.php' );
}

?> <div class="wrap nosubsub"> <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> <?php
if ( is_network_admin() ) {
                foreach ( $plugins as $i => $plugin ) {
                    // Only activate plugins which are not already network activated.                     if ( is_plugin_active_for_network( $plugin ) ) {
                        unset( $plugins[ $i ] );
                    }
                }
            } else {
                foreach ( $plugins as $i => $plugin ) {
                    // Only activate plugins which are not already active and are not network-only when on Multisite.                     if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) {
                        unset( $plugins[ $i ] );
                    }
                    // Only activate plugins which the user can activate.                     if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
                        unset( $plugins[ $i ] );
                    }
                }
            }

            if ( empty( $plugins ) ) {
                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s) );
                
return apply_filters( 'shortcut_link', $link );
}

/** * Ajax handler for saving a post from Press This. * * @since 4.2.0 * @deprecated 4.9.0 */
function wp_ajax_press_this_save_post() {
    _deprecated_function( __FUNCTION__, '4.9.0' );
    if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
        include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
        $wp_press_this = new WP_Press_This_Plugin();
        $wp_press_this->save_post();
    } else {
        wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
    }
}

/** * Ajax handler for creating new category from Press This. * * @since 4.2.0 * @deprecated 4.9.0 */
public function __construct( $args = array() ) {
        $defaults = array(
            'url'    => '',
            'plugin' => '',
            'nonce'  => '',
            'title'  => __( 'Update Plugin' ),
        );
        $args     = wp_parse_args( $args$defaults );

        $this->plugin = $args['plugin'];

        $this->plugin_active         = is_plugin_active( $this->plugin );
        $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );

        parent::__construct( $args );
    }

    /** * Performs an action following a single plugin update. * * @since 2.8.0 */
    public function after() {
        
protected function check_read_permission( $plugin ) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';

        if ( ! $this->is_plugin_installed( $plugin ) ) {
            return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) );
        }

        if ( ! is_multisite() ) {
            return true;
        }

        if ( ! is_network_only_plugin( $plugin ) || is_plugin_active( $plugin ) || current_user_can( 'manage_network_plugins' ) ) {
            return true;
        }

        return new WP_Error(
            'rest_cannot_view_plugin',
            __( 'Sorry, you are not allowed to manage this plugin.' ),
            array( 'status' => rest_authorization_required_code() )
        );
    }

    /** * Checks if a given request has access to upload plugins. * * @since 5.5.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */


    if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) {
        $status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' );
        wp_send_json_error( $status );
    }

    $plugin_data          = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
    $status['plugin']     = $plugin;
    $status['pluginName'] = $plugin_data['Name'];

    if ( is_plugin_active( $plugin ) ) {
        $status['errorMessage'] = __( 'You cannot delete a plugin while it is active on the main site.' );
        wp_send_json_error( $status );
    }

    // Check filesystem credentials. `delete_plugins()` will bail otherwise.     $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );

    ob_start();
    $credentials = request_filesystem_credentials( $url );
    ob_end_clean();

    
$plugins        = get_plugins();
        $plugin_updates = get_plugin_updates();

        $plugins_active      = 0;
        $plugins_total       = 0;
        $plugins_need_update = 0;

        // Loop over the available plugins and check their versions and active state.         foreach ( $plugins as $plugin_path => $plugin ) {
            $plugins_total++;

            if ( is_plugin_active( $plugin_path ) ) {
                $plugins_active++;
            }

            if ( array_key_exists( $plugin_path$plugin_updates ) ) {
                $plugins_need_update++;
            }
        }

        // Add a notice if there are outdated plugins.         if ( $plugins_need_update > 0 ) {
            $result['status'] = 'critical';

            
<?php elseif ( is_wp_error( $edit_error ) ) : ?> <div id="message" class="notice notice-error"> <p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p> <pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre> </div> <?php endif; ?> <div class="fileedit-sub"> <div class="alignleft"> <h2> <?php     if ( is_plugin_active( $plugin ) ) {
        if ( is_writable( $real_file ) ) {
            /* translators: %s: Plugin file name. */
            printf( __( 'Editing %s (active)' ), '<strong>' . esc_html( $file ) . '</strong>' );
        } else {
            /* translators: %s: Plugin file name. */
            printf( __( 'Browsing %s (active)' ), '<strong>' . esc_html( $file ) . '</strong>' );
        }
    } else {
        if ( is_writable( $real_file ) ) {
            /* translators: %s: Plugin file name. */
            printf( __( 'Editing %s (inactive)' ), '<strong>' . esc_html( $file ) . '</strong>' );
        }
$this->skin->bulk_header();

        /* * Only start maintenance mode if: * - running Multisite and there are one or more plugins specified, OR * - a plugin with an update available is currently active. * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible. */
        $maintenance = ( is_multisite() && ! empty( $plugins ) );
        foreach ( $plugins as $plugin ) {
            $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) );
        }
        if ( $maintenance ) {
            $this->maintenance_mode( true );
        }

        $results = array();

        $this->update_count   = count( $plugins );
        $this->update_current = 0;
        foreach ( $plugins as $plugin ) {
            $this->update_current++;
            
 else {
                                $action_links[] = sprintf(
                                    '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
                                    _x( 'Cannot Update', 'plugin' )
                                );
                            }
                        }
                        break;

                    case 'latest_installed':
                    case 'newer_installed':
                        if ( is_plugin_active( $status['file'] ) ) {
                            $action_links[] = sprintf(
                                '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
                                _x( 'Active', 'plugin' )
                            );
                        } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) {
                            if ( $compatible_php && $compatible_wp ) {
                                $button_text = __( 'Activate' );
                                /* translators: %s: Plugin name. */
                                $button_label = _x( 'Activate %s', 'plugin' );
                                $activate_url = add_query_arg(
                                    array(
                                        

function is_plugin_inactive( $plugin ) {
    return ! is_plugin_active( $plugin );
}

/** * Determines whether the plugin is active for the entire network. * * Only plugins installed in the plugins/ folder can be active. * * Plugins in the mu-plugins/ folder can't be "activated," so this function will * return false for those plugins. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 3.0.0 * * @param string $plugin Path to the plugin file relative to the plugins directory. * @return bool True if active for the network, otherwise false. */
Home | Imprint | This part of the site doesn't use cookies.