我创建(或更好地尝试)用Less创建我的第一个WordPress主题.
我所做的是在我的functions.php中使用这样的脚本
wp_register_style('screen_css', get_bloginfo('template_url') . '/css/screen.less', array(), false, 'screen');
wp_enqueue_style('screen_css');
Run Code Online (Sandbox Code Playgroud)
结果是:
<link rel='stylesheet' id='stigma_screen-css' href='http://www.stigmahost.dch/wp-content/themes/stigmahost/css/screen.less?ver=1.0' type='text/css' media='screen' />
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用wp_register_style()函数时,我可以以某种方式更改rel ="stylesheet"吗?
你好我有这样的代码:
try
{
// Here I call my external function
do_some_work()
}
catch(Exception $e){}
Run Code Online (Sandbox Code Playgroud)
问题是:如果do_some_work()出现问题并产生错误,那么try catch会隐藏错误吗?
我想知道是否有任何方法可以知道插件是否刚刚安装.我不在乎它是否已激活,但只有安装了该插件!
你知道有什么好办法吗?
我必须更加具体.我知道在哪里可以找到插件,我知道如何安装可以看到.问题是,如果有任何编程方式来检查插件是否已安装.
即:WordPress为我们提供了register_activation_hook(),以便在插件激活时进行我们喜欢的任何操作,但是没有任何相关的插件安装挂钩.有没有办法确定插件安装?
服务器变量是否HTTP_HOST始终为所有服务器定义,或者例如在IIS中使用其他名称定义,甚至根本没有定义?
此外,该值始终定义?或者某些主持人他们没有定义这个价值?有没有其他方法来检索该值?
我有一个这样的字符串:
[0-9A-Za-z\+/=]*
Run Code Online (Sandbox Code Playgroud)
我怎样才能转换成以下形式:
"\133\x30\55\x39\101\x2d\132\x61\55\x7a\134\x2b\57\x3d\135\x2a"
Run Code Online (Sandbox Code Playgroud)
那有什么功能吗?
我已经通过PEAR安装了PHPUnit,并且我已经安装了WordPress插件测试(https://github.com/tierra/wordpress-plugin-tests)来测试我正在开发的WordPress插件.
测试运行正常的问题,我得到以下输出:
Running as single site... To run multisite, use -c multisite.xml
Not running ajax tests... To execute these, use --group ajax.
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from E:\LocalWebServer\dch\c\my-wp-installtion.dch\wordpress-test\wordpress\wp-content\plugins\myplugin\phpunit.xml
[41;37mF[0m.[36;1mS[0m
Time : 1 second, Memory: 30.50Mb
There was 1 failure:
1) CDOAjax_Tests::test_tests
Failed asserting that false is true.
E:\LocalWebServer\dch\c\my-wp-installtion.dch\wordpress-test\wordpress\wp-content\plugins\myplugin\Tests\test_CDOAjax_tests.php:7
[37;41m[2KFAILURES!
[0m[37;41m[2KTests: 3, Assertions: 2, Failures: 1, Skipped: 1.
[0m[2K
Run Code Online (Sandbox Code Playgroud)
我不知道这是否有帮助,但phpunit.xml包含以下内容:
<phpunit
bootstrap="bootstrap_tests.php"
backupGlobals="false"
colors="true"
>
<testsuites>
<!-- Default test suite to run all tests -->
<testsuite …Run Code Online (Sandbox Code Playgroud) 我正在为我的客户构建目录主题,我喜欢通过将帖子状态从发布修改为过期来在帖子中添加过期功能.
为此,我尝试使用以下代码注册新的帖子状态:
add_action('init', 'registerStatus', 0);
function registerStatus()
{
$args = array(
'label' => _x('Expired', 'Status General Name', 'z' ),
'label_count' => _n_noop('Expired (%s)', 'Expired (%s)', 'z'),
'public' => true,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'exclude_from_search' => true
);
register_post_status('expired', $args);
}
Run Code Online (Sandbox Code Playgroud)
问题是我无法在自定义帖子类型的帖子状态中看到WordPress帖子中的已注册帖子状态.
难道我做错了什么?
我是Laravel的新手,我已经实现了User提供的表Laravel Auth,并且我还为用户元数据创建了一个表Key Value pare table.
用户元表由以下代码创建:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UserMeta extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_meta', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->char('meta_key', 255);
$table->longText('meta_value')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('user_meta');
}
}
Run Code Online (Sandbox Code Playgroud)
在我的User model我有以下方法:
public function meta() {
return $this->hasMany('App\Models\UserMeta');
}
Run Code Online (Sandbox Code Playgroud)
在我的内部我UserMeta model …
我目前有一个Angular Directive,用于验证密码并确认密码字段为匹配.它适用于某一点,当密码不匹配时它会抛出错误.但是,在两个字段中输入数据之前,它不会抛出错误.如何在一个字段或另一个字段中输入数据后立即抛出不匹配密码的错误?
这是指令(必须将其添加到需要匹配的两个字段中):
.directive('passwordVerify', function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
link: function(scope, elem, attrs, ngModel) {
//if (!ngModel) return; // do nothing if no ng-model
// watch own value and re-validate on change
scope.$watch(attrs.ngModel, function() {
validate();
});
// observe the other value and re-validate on change
attrs.$observe('passwordVerify', function(val) {
validate();
});
var validate = function() {
// values
var val1 = ngModel.$viewValue;
var val2 = …Run Code Online (Sandbox Code Playgroud) 我救出了一个原本只为西班牙观众写的旧项目,现在我必须把它国际化.
该项目有3种文本字符串:
<html>...<body>...<p>Hello world</p>...首先不是问题,因为实际上很少有字符串并且非常本地化.第二种情况也非常本地化,所以这不是一个大问题.但最后2个案例是无法诠释的:数百个HTML文件(静态+数据库)里面有数百个字符串.
所以,我正在寻找一种自动化方法,将所有字符串提取为可识别的格式,将其提供给翻译人员,然后将我的页面用于其他语言.
是否存在类似的东西,还是应该创建自定义解决方案?在这种情况下,任何想法?