在wordpress中,我试图在看到任何内容之前先强制用户登录.意味着我希望我的用户首先登录以查看任何单个页面,发布或存档,只有他们可以查看常见问题页面.我正在尝试下面的代码,但问题是我插入后,它再次重定向到登录页面.
但是我的网站结构如下所示,同样我想要这个代码工作......
// Force user to login on welcome
function my_force_login() {
global $post;
if (is_single() || is_front_page() || is_page() && !is_page('login') && !is_user_logged_in()){
auth_redirect();
}
}
Run Code Online (Sandbox Code Playgroud)
Welcomd-Login屏幕(如facebook)-Home page -Blog -About -contact -FAQ
所以我想允许访问者只能看到欢迎登录屏幕和常见问题,联系页面查看我想强制他们登录的网站的其余部分..
我需要你们的大力帮助..非常感谢...
我正在使用Bootstrap Switch进行Twitter Bootstrap.在这里,我有问题检查或取消选中基于全局复选框选中或取消选中的所有复选框
这是bootstrap交换机链接http://www.bootstrap-switch.org/
这就是我所做的
<!-- this is the global checkbox -->
<div class="make-switch switch-mini">
<input type="checkbox" id="rowSelectAll">
</div>
<!-- row checkboxs -->
<div class="make-switch switch-mini">
<input type="checkbox" class="row-select">
</div>
<div class="make-switch switch-mini">
<input type="checkbox" class="row-select">
</div>
<div class="make-switch switch-mini">
<input type="checkbox" class="row-select">
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$("#rowSelectAll").click(function () {
$(".row-select").prop('checked', $(this).prop('checked'));
});
Run Code Online (Sandbox Code Playgroud)
编辑:尝试只有一个全局和一个本地复选框
<div class="make-switch switch-mini">
<input type="checkbox" id="rowSelectAll">
</div>
<div id="toggle-state-switch" class="make-switch switch-mini row-select">
<input type="checkbox" class="">
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试超过3个小时为github设置多个帐户并且疲惫不堪.我已经尝试了几乎所有可能的方式在这里描述,github和文章,但没有一个工作.我也是github和Unix的新手.所以需要你的帮助来解决这个问题.在下面我正在做什么
我正在使用Windows 7并为两个不同的帐户设置了两个ssh密钥.
比在.sshUser的目录中创建配置文件并添加到代码下面
#Account one
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile /c/Projects/.ssh/id_rsa
#Account two
Host ac2.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile /c/Projects/.ssh/id_rsa_ac2
Run Code Online (Sandbox Code Playgroud)
现在我尝试使用下面的代码添加远程
git remote add origin git@ac2.github.com:myaccount/my.git
Run Code Online (Sandbox Code Playgroud)
并用波纹管代码推送
git push origin master
Run Code Online (Sandbox Code Playgroud)
但是,当我试图推动它给我错误:
Error: Permission to myaccount/my.git denied to {account}. // where it is considering default user account and not for ac2 user account
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository …
我正在学习OOP,并且非常混淆彼此使用类.
我共有3节课
//CMS System class
class cont_output extends cont_stacks
{
//all methods to render the output
}
//CMS System class
class process
{
//all process with system and db
}
// My own class to extends the system like plugin
class template_functions
{
//here I am using all template functions
//where some of used db query
}
Run Code Online (Sandbox Code Playgroud)
现在我想使用我自己的类template_functions和两个系统类.但很困惑如何使用它.请帮我理解这个.
编辑:我很抱歉,我忘了在不同的PHP文件中提到我自己的班级.
我正在尝试向我的网站添加自定义推文按钮,一切都很好,但它没有缩短URL.我使用的是URL查询字符串而不是javascript.是这样的吗?
<a class="btn btn-tweet" target="_blank" href="https://twitter.com/share?text='.$title.'&url='.$url.'&via='.$user.'&wrap_links=true">Twitter</a>
Run Code Online (Sandbox Code Playgroud)
我已经阅读了一些API文档并说上面的19个字符的twitter缩短了url本身.只是想知道它为什么不用这个转换.
我也无法在弹出窗口而不是新窗口中打开.如果不添加任何单独的javascript代码但直接内联在锚标记中,这一切都可能吗?
我在自己的文件中有两个类在同一个文件夹中.但是当我试图将一个扩展到另一个时,它会给命名空间和类找不到错误.
信息:这是我第一次使用命名空间扩展类.嵌套命名空间对我来说也是新的.
DB\CRUD所以我可能在完全错误的命名空间.
Fatal error: Class 'DB\AT_Database' not found in /var/www/...
Run Code Online (Sandbox Code Playgroud)
文件:AT_Database.php
namespace DB;
class AT_Database
{
...
}
Run Code Online (Sandbox Code Playgroud)
文件:AT_CRUD.php
namespace DB\CRUD;
use DB\AT_Database;
class AT_CRUD extends AT_Database
{
public function __construct()
{
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Laravel Auth 和 Socialite 包进行社交登录。我也有不同的用户角色,并根据角色在不同的页面上重定向它们。
从LoginController > authenticated()方法处理 Auth 登录用户的重定向。
public function authenticated(Request $request, $user)
{
if (auth()->check()) {
if (in_array($user->role, $this->getAdminRoles())) {
return redirect(route('admin.dashboard'));
}
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常并根据用户的角色重定向用户。但是,这仅在他们以传统方式登录时才有效。
如果用户使用任何社交渠道登录,重定向将不起作用。我意识到社交登录重定向 Handel 从其处理程序方法。为此,我有一个特征如下。所以我可以在 RegisterController 上使用它来避免代码重复。
namespace App\Traits;
use App\SocialProvider;
use App\User;
use DateTime;
use Exception;
use Illuminate\Support\Facades\Auth;
use Laravel\Socialite\Facades\Socialite;
use function is_null;
use function preg_replace;
use function redirect;
use function strtolower;
trait SocialAuthHandler
{
/**
* Redirect the user to the GitHub authentication page.
* …Run Code Online (Sandbox Code Playgroud) 使用ShapeableImageView材质组件并设置shapeAppearanceOverlay为圆形图像时出现问题。它不会出现在视口中。似乎我们将可见性设置为GONE。但是,它在设备上完美显示。
有什么办法可以解决吗?或者因为它仍在1.2.0-alpha05开发中或已知错误?
implementation 'com.google.android.material:material:1.2.0-alpha05'
Run Code Online (Sandbox Code Playgroud)
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/v_blog_card_avatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/splash_background"
android:scaleType="centerCrop"
app:shapeAppearanceOverlay="@style/ImageCircleTheme"
app:layout_constraintTop_toBottomOf="@+id/v_blog_card_divider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="16dp"
android:layout_marginStart="16dp"/>
Run Code Online (Sandbox Code Playgroud)
<style name="ImageCircleTheme">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我试图通过检查是否存在来添加列.如果不是,它应该通过下面的代码给出它已经存在的消息.
$prefix = 'vm_';
$col_name = 'checking';
$col = "SELECT ".$col_name." FROM ".$prefix."users";
if (!$col){
$insert_col = "ALTER TABLE ".$table." ADD ".$col_name." DATETIME NOT NULL";
mysql_query($insert_col);
echo $col_name.' has been added to the database';
} else {
echo $col_name.' is already exists';
}
Run Code Online (Sandbox Code Playgroud)
但它不会添加任何列并直接显示该列已存在的消息.
我想在用户点击删除链接时删除文件.但是当我进入我的页面时,该文件被删除,我不知道为什么:
echo '<h3><a onclick="'.unlink(__FILE__).'">Delete Now!</a></h3>';
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?