
WordPress Salts是什么及如何使用它们
wp_get_active_and_valid_plugins ( No parameters )
wp_get_active_and_valid_plugins: 这个函数返回一个活动和有效插件的数组。它扫描插件目录并检索所有以”.php”结尾的文件的列表。然后它检查每个文件以确保它有一个有效的插件头。
检索一个活跃和有效的插件文件数组。
在升级或安装WordPress时,不返回插件。
默认目录是`wp-content/plugins`。要手动改变默认目录,在`wp-config.php`中定义`WP_PLUGIN_DIR`和`WP_PLUGIN_URL`。
function wp_get_active_and_valid_plugins() { $plugins = array(); $active_plugins = (array) get_option( 'active_plugins', array() ); // Check for hacks file if the option is enabled. if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { _deprecated_file( 'my-hacks.php', '1.5.0' ); array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); } if ( empty( $active_plugins ) || wp_installing() ) { return $plugins; } $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; foreach ( $active_plugins as $plugin ) { if ( ! validate_file( $plugin ) // $plugin must validate as file. && '.php' === substr( $plugin, -4 ) // $plugin must end with '.php'. && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. // Not already included as a network plugin. && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) ) ) { $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; } } /* * Remove plugins from the list of active plugins when we're on an endpoint * that should be protected against WSODs and the plugin is paused. */ if ( wp_is_recovery_mode() ) { $plugins = wp_skip_paused_plugins( $plugins ); } return $plugins; }