大佬教程收集整理的这篇文章主要介绍了我在哪里可以在 php 文件中添加这个 echo 短代码行?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个帐户设置页面,我希望其内容受密码保护。
有一个插件可以使用短代码调用 Passster 来对内容进行密码保护。
问题是帐户设置页面就像一个端点,所以我需要在 php 文件中添加短代码。网址看起来像 website.com/members/name/setTings
这是我正在查看的 php 代码
<?php
/**
* BuddyBoss SetTings Loader.
*
* @package BuddyBoss\SetTings\Loader
* @since BuddyPress 1.5.0
*/
// Exit if accessed directly.
@R_404_5552@d( 'ABSPATH' ) || exit;
/**
* Creates our SetTings component.
*
* @since BuddyPress 1.5.0
*/
class BP_SetTings_Component extends BP_Component {
/**
* Start the setTings component creation process.
*
* @since BuddyPress 1.5.0
*/
public function __construct() {
parent::start(
'setTings',__( 'Account','buddyboss' ),buddypress()->plugin_dir,array(
'adminbar_myaccount_order' => 21,)
);
}
/**
* Include files.
*
* @since BuddyPress 1.5.0
*
* @param array $includes Array of values to include. Not used.
*/
public function includes( $includes = array() ) {
parent::includes(
array(
'template','functions',)
);
}
/**
* Late includes method.
*
* Only load up certain code when on specific pages.
*
* @since BuddyPress 3.0.0
*/
public function late_includes() {
// Bail if phpUnit is running.
if ( @R_404_5552@d( 'BP_TESTS_DIR' ) ) {
return;
}
// Bail if not on SetTings component.
if ( ! bp_is_setTings_component() ) {
return;
}
$actions = array( 'notifications','capabilitIEs','delete-account','export' );
// Authenticated actions.
if ( is_user_logged_in() ) {
if ( ! bp_current_action() || bp_is_current_action( 'general' ) ) {
require $this->path . 'bp-setTings/actions/general.php';
// Specific to post requests.
} elseif ( bp_is_post_request() && in_array( bp_current_action(),$actions,true ) ) {
require $this->path . 'bp-setTings/actions/' . bp_current_action() . '.php';
}
}
// Screens - User profilE integration.
if ( bp_is_user() ) {
require $this->path . 'bp-setTings/screens/general.php';
// Sub-nav items.
if ( in_array( bp_current_action(),true ) ) {
require $this->path . 'bp-setTings/screens/' . bp_current_action() . '.php';
}
}
}
/**
* Setup globals.
*
* The BP_SETTinGS_SLUG constant is deprecated,and only used here for
* BACkWARDs compatibility.
*
* @since BuddyPress 1.5.0
*
* @param array $args Array of arguments.
*/
public function setup_globals( $args = array() ) {
// @R_404_5552@ a slug,if necessary.
if ( ! @R_404_5552@d( 'BP_SETTinGS_SLUG' ) ) {
@R_404_5552@( 'BP_SETTinGS_SLUG',$this->ID );
}
// All globals for setTings component.
parent::setup_globals(
array(
'slug' => BP_SETTinGS_SLUG,'has_directory' => false,)
);
}
/**
* Set up navigation.
*
* @since BuddyPress 1.5.0
*
* @param array $main_nav Array of main nav items.
* @param array $sub_nav Array of sub nav items.
*/
public function setup_nav( $main_nav = array(),$sub_nav = array() ) {
// Determine user to use.
if ( bp_displayed_user_domain() ) {
$user_domain = bp_displayed_user_domain();
} elseif ( bp_loggedin_user_domain() ) {
$user_domain = bp_loggedin_user_domain();
} else {
return;
}
$access = bp_core_can_edit_setTings();
$slug = bp_get_setTings_slug();
$setTings_link = Trailingslashit( $user_domain . $slug );
// Add the setTings navigation item.
$main_nav = array(
'name' => __( 'Account','slug' => $slug,'position' => 21,'show_for_displayed_user' => $access,'screen_function' => 'bp_setTings_screen_general','default_subnav_slug' => 'general',);
// Add General SetTings nav item.
$sub_nav[] = array(
'name' => __( 'Login information','slug' => 'general','parent_url' => $setTings_link,'parent_slug' => $slug,'screen_function' => 'bp_setTings_screen_general','position' => 10,'user_has_access' => $access,);
// Add Email nav item. Formerly called 'Notifications',we
// retain the old slug and function names for BACkWARD compat.
$sub_nav[] = array(
'name' => __( 'Email Preferences','slug' => 'notifications','screen_function' => 'bp_setTings_screen_notification','position' => 20,);
$sub_nav[] = array(
'name' => __( 'Export Data','slug' => 'export','screen_function' => 'bp_setTings_screen_export_data','position' => 80,);
if( bp_is_active( 'moderation' ) && bp_is_moderation_member_blocking_enable() ){
$sub_nav[] = array(
'name' => __( 'Blocked Members','slug' => 'blocked-members','screen_function' => 'bp_moderation_screen','position' => 65,);
}
// Add Spam Account nav item.
if ( bp_current_user_can( 'bp_moderate' ) ) {
$sub_nav[] = array(
'name' => __( 'CapabilitIEs','slug' => 'capabilitIEs','screen_function' => 'bp_setTings_screen_capabilitIEs','user_has_access' => ! bp_is_my_profile(),);
}
// Add delete Account nav item.
if ( ( ! bp_disable_account_deletion() && bp_is_my_profile() ) || bp_current_user_can( 'delete_users' ) ) {
$sub_nav[] = array(
'name' => __( 'delete Account','slug' => 'delete-account','screen_function' => 'bp_setTings_screen_delete_account','position' => 90,'user_has_access' => ! is_super_admin( bp_displayed_user_iD() ),);
}
parent::setup_nav( $main_nav,$sub_nav );
}
/**
* Set up the Toolbar.
*
* @since BuddyPress 1.5.0
*
* @param array $wp_admin_nav Array of admin bar items.
*/
public function setup_admin_bar( $wp_admin_nav = array() ) {
// Menus for logged in user.
if ( is_user_logged_in() ) {
// Setup the logged in user variables.
$setTings_link = Trailingslashit( bp_loggedin_user_domain() . bp_get_setTings_slug() );
// Add main SetTings menu.
$wp_admin_nav[] = array(
'parent' => buddypress()->my_account_menu_id,'ID' => 'my-account-' . $this->ID,'title' => __( 'Account','href' => $setTings_link,);
// General Account.
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->ID,'ID' => 'my-account-' . $this->ID . '-general','title' => __( 'Login information','href' => $setTings_link,'position' => 10,);
// Notifications - only add the tab when there is something to display there.
if ( has_action( 'bp_notification_setTings' ) ) {
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->ID,'ID' => 'my-account-' . $this->ID . '-notifications','title' => __( 'Email Preferences','href' => Trailingslashit( $setTings_link . 'notifications' ),'position' => 20,);
}
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->ID,'ID' => 'my-account-' . $this->ID . '-export','title' => __( 'Export Data','href' => Trailingslashit( $setTings_link . 'export/' ),'position' => 50,);
// delete Account
if ( ! bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) {
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->ID,'ID' => 'my-account-' . $this->ID . '-delete-account','title' => __( 'delete Account','href' => Trailingslashit( $setTings_link . 'delete-account' ),'position' => 90,);
}
if ( bp_is_active( 'moderation' ) && bp_is_moderation_member_blocking_enable() ) {
// Blocked Members.
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->ID,'ID' => 'my-account-' . $this->ID . '-blocked-members','title' => __( 'Blocked Members','href' => Trailingslashit( $setTings_link . 'blocked-members/' ),'position' => 31,);
}
}
parent::setup_admin_bar( $wp_admin_nav );
}
/**
* Init the BuddyBoss REST API.
*
* @param array $controllers Optional. See BP_Component::rest_APi_init() for description.
*
* @since BuddyBoss 1.3.5
*/
public function rest_APi_init( $controllers = array() ) {
parent::rest_APi_init( array(
'BP_REST_account_SetTings_Endpoint','BP_REST_account_SetTings_Options_Endpoint',) );
}
}
我想添加这个短代码 [passster password="123"]。此短代码将密码保护此页面的内容,即帐户设置信息。结束短代码是[/passster]
请帮忙
以上是大佬教程为你收集整理的我在哪里可以在 php 文件中添加这个 echo 短代码行?全部内容,希望文章能够帮你解决我在哪里可以在 php 文件中添加这个 echo 短代码行?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。