WordPress插件开发记录
1.a标签在新的网页中打开内容
<a href="网址" target="_blank"></a>
2.PDO的$request->fetchAll(PDO::FETCH_ASSOC);
fetchAll
3.datatables waring(table id = 'xx'):cannot reinitialise datatable
如果出现这种错误是因为在一个网页中加载了两次DataTables
1.查找HTML网页中是否有两次加载js
2.查看JS代码是否有两次初始化DT
4.PHP解析JSON字符串
直接使用json_decode解析出来的类型为:对象
如果在使用中加上参数true解析出来的为:数组
<?php
$json = '{"a":"php","b":"mysql","c":3}';
$json_Class=json_decode($json);
$json_Array=json_decode($json, true);
print_r($json_Class);
print_r($json_Array);
?>
访问对象类型$json_Class的a的值:echo $json_Class->{'a'};
访问数组类型$json_Array的a的值:echo $json_Array['a'];
5.add_action 将函数连接到指定action(动作)。
http://www.wpdaxue.com/add_action.html
6.add_options_page
add_options_page(
$page_title:当菜单被选中时候,这个文本被显示在Title标记中
$menu_title:菜单的文本显示
$capability: 当前用户是否有权利浏览这个页面
$menu_slug: 菜单将引用这个slug的名字(对于菜单来说应该是唯一的)
$function:这个方法中的的内容将白调用输出到菜单说点击的页面
)
7.URLEncoder.encode("微信截图", "UTF-8");
8.查询删除表中的数据
DELETE FROM t_posts WHERE id IN ( select * from( SELECT id FROM t_posts WHERE post_content LIKE '%?resize=%') as t);
9.在删除t_topic表中的数据的时候,要除去post_content为空的记录。使用 delete from t_topic where post_content is null 不行。后来使用 = '' 才可以
10.MySql删除一列有相同内容的数据
select distinct(post_content) from t_posts
http://www.open-open.com/lib/view/open1404568229186.html
http://www.111cn.net/database/mysql/56725.htm
查询表中重复的记录:
select post_content from t_posts group by post_content having count(post_content) > 1
查询出表中内容重复的id
select id from t_posts group by post_content having count(post_content) >1
11.$draw = $_GET['draw']; //第几次请求
12.zTree
13.DataTable分页处理数据
1.在处理分页数据的时候,如果要使用服务器端分页,那么不能使用sAjaxSource进行ajax请求,只能使用ajax的方式请求。
2.如果要使用服务器分页,则需要设置字段serverSide为true,并使用ajax
3.还要注意查API文档,客户端会给服务器发送什么字段,服务器要返回什么字段。同时要注意字段的名称,在网上有很多种版本,参考官方。
http://datatables.club/manual/server-side.html
发送参数: 返回的数据:
1.draw 1.draw
2.start 2.recordsTotal 即没有过滤的记录数(数据库里总共记录数)
3.length 3.recordsFiltered 过滤后的记录数(如果有接收到前台的过滤条件,则返回的是过滤后的记录数)
14.在PHP查询中,如果查询的条件中含有字符串,那么在构建SQL语句时应该加上单引号
$query = "select keywords from topic where uuid = '$uuid'";
15.Undefined offset: 0 in
数组为空,然后直接使用$res[0]去获取值
16.在拼接字符串时出现的问题
<input type="button" name="sub" onclick="postData(\''+row.uuid+'\')" value="确认" class="btn btn-success btn-sm"/>
如果row.uuid为数字,那么正常 postData(1)
如果row.uuid为字幕,那么传递的参数为: postData(aaa),正确的为:postData('aaa')
17.aptana
18.PHP判断获取到的POST值是否为空
if(!empty($_POST['uuid'])){
$uuid = $_POST['uuid'];
}else{}
19.查看php-fpm状态
service php-fpm status
20.mysql语句怎么将数据库中某个字段的所有值全部替换成另一个值?
update table set a=REPLACE(a,'1','2');
a 为字段名 例:a字段中,把1改为2.
update t_posts set post_content = REPLACE(post_content,'www.goldenlauncher.com/wordpress','www.goldenmob.com');
21.PHP拼接字符串
$condition = $condition."uuid = '".$uuid."'";
select author,title,app_category,content,keywords,add_time,domain,image_count,uuid,tags,custom_tag from topic where {$condition} order by add_time desc limit {$start},{$length}
22.在DT进行搜索的时候,这个时候所查出来的总数会改变,有没有办法在一条SQL语句中,将当前的查询出来的条数查出来?
23.删除特定数据
DELETE
FROM
topic
WHERE
uuid IN (
SELECT
*
FROM
(
SELECT
uuid
FROM
topic
WHERE
content LIKE '<img src=%'
) AS t
);
24.显示在主菜单栏
public function register_my_custom_menu_page(){
if(function_exists('add_menu_page')){
add_menu_page("WP Fastest Cache Settings", "WP Fastest Cache", 'manage_options', "wpfastestcacheoptions", array($this, 'optionsPage'), plugins_url("wp-fastest-cache/images/icon-32x32.png"), "99.".time() );
wp_enqueue_style("wp-fastest-cache", plugins_url("wp-fastest-cache/css/style.css"), array(), time(), "all");
}
25.需要注意的是,由于在WordPress中可以配置wp-content/plugins/目录的位置,所以你必须使用plugin_dir_path()和plugins_url()两个函数来获取插件的路径。
plugin_dir_path 使用来获取插件绝对路径
wp_enqueue_script 用来将插件加载
/**
* Enqueue a script with jQuery as a dependency.
*/
function wpdocs_scripts_method() {
wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_scripts_method' );
protected function getWpContentDir(){
return WPFC_WP_CONTENT_DIR;
}
添加关键字 tags
设置等级
WordPress插件开发记录的更多相关文章
- 黄聪:《跟黄聪学WordPress插件开发》
续<跟黄聪学WordPress主题开发>之后,又一个作品完成!<跟黄聪学Wordpress插件开发>,国内最好的Wordpress插件开发视频教程!! 目录预览: WordPr ...
- WORDPRESS插件开发(二)HELLO WORLD改进版
在上一篇文章中WORDPRESS插件开发(一)HELLO WORLD,演示了Hello World的最简单实现,只是在每篇文章的后面加入Hello World字符,而且字符也是写死的. 如果用户需要自 ...
- WORDPRESS插件开发学习(一)HELLO WORLD
WORDPRESS插件开发学习系列文章第一篇,在每篇文章的后面追加固定的字符“Hello World” 一.打开wordpress目录->wp-content->plugins 二.在pl ...
- 《WordPress插件开发手冊》文件夹
翻译前言:国内没有关于WordPress插件开发比較具体而且系统的资料 前言 第一章:准备一个本地开发环境 介绍 在你的电脑上安装一个站点server 下载并配置一个本地的WordPress 创建一个 ...
- wordpress插件开发流程梳理
1.声明一个插件 首先我们必须明白,wordpress的插件可以是单文件,也可以是多文件,css/html都不是必须的,以下举例暂且在单文件模式下 比如我们要创建一个名为 hellophp的插件,那我 ...
- WordPress插件开发实例教程 - 版权插件
说明:本教程仅限学习,高手请绕道 开发程序:WordPress 3.9-RC1 使用主题:Twenty Fourteen 在开始之前,需要注意三件事情 I.给插件取一个个性化的名字,越个性化越好,以防 ...
- WordPress使用记录
主要记录WordPress4.7使用过程中遇到的一些问题及解决办法. 1.无法显示主题列表 问题:新的版本主题管理页面是只显示当前主题的,无法进行管理. 解决:修改php.ini文件,参考这里.
- wordpress安装记录
wordpress 已经完全部署到Linux后,进行开始安装的时候,数据库信息都填入好了(前提是:链接信息输入都正确) 然后点击会报错,说是链接数据库失败(数据库是建在阿里云服务器上的),但是具体不知 ...
- 目前项目wordpress插件记录
Restrict User Content WordPress 后台只显示当前登录用户的文章.页面和媒体 Client Dash 可以根据不同的角色生成不同的后台的菜单
随机推荐
- MySQL常用时间函数
官方文档:Date and Time Functions Name Description ADDDATE() Add time values (intervals) to a date value ...
- OR扩展
<pre name="code" class="sql">SQL> select substr(xx.acct_no,1,5) agent_o ...
- jQuery自定义函数验证邮箱格式
jQuery.fn.checkEmail = function() { // 自定义jQuery方法 var email_val = $(this).val(); reg = /^\w+([-+.]\ ...
- Temporary failure in name resolution
公司搬家,在一台测试机上执行git clone,出现错误 ssh: Could not resolve hostname **: Temporary failure in name resolutio ...
- POJ3580---SuperMemo (Splay)
各种操作,区间更新,求最值.翻转.插入.删除.当然是Splay这种神器了. 主要是 revolve这个操作,其实也就是3个区间翻转放到一块, 比如 REVOLVE x y T,T %= (y-x+1) ...
- sicily 1007 To and Fro
题意:字符串的操作处理 // Problem#: 8768 // Submission#: 2606406 // The source code is licensed under Creative ...
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 解决办法
Maven install失败 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (d ...
- Homebrew新一代OS X套件管理工具 高速安装Git
在Mac上安装一些开源程序,除了自己下下载.编译( ./configure && make && make install) 之外,通常最方便的选择就是用套件管理工具來 ...
- SpringTest2
Spring 框架第二天 AOP切面编程 今天重点内容: 1. 什么是AOP ? AOP实现原理是怎样的? AOP相关术语 2. AOP底层实现 (了解) ----- JDK动态代理. Cglib动态 ...
- XML基本知识
一.xml简介 1.xml(可扩展标记语言),是一种标记语言,类似于html,其作用主要是传输数据,并非显示数据! 2.xml标签没有被预定义需要用户自行定义. 3.xml由w3c组织发布,遵循200 ...