search
HomeBackend DevelopmentPHP TutorialPHP中wordpress的一些修改及wordpress技巧

不知算不算手贱,把VPS服务器上的php升级到7.0, 虽然7.x与之前的兼容性是很高的,但移除了一大堆过时用法,而某些老应用仍然在使用。对个人wordpress站点里出现的错误,修正记录如下。全部是插件,wordpress官方程序,是没有问题的。

mysql_escape_string() 函数改为addslashes()

wp-thread-comment插件 wp-content/plugins/wordpress-thread-comment/wp-thread-comment.php 有多处

mysql_* 系列函数在php7里全部移除了,所以建议在所有文件里搜索一下 mysql_query, mysql_escape_, mysql_real_eacape 等函数,如: grep -r mysql_query /path/to/your/site

split()函数改为explode()

auto-save-image插件 wp-content/plugins/auto-save-image/auto-save-image.php 122行

语法兼容

Configure SMTP插件 wp-content/plugins/configure-smtp/configure-smtp.php 171行,为函数定义添加默认值

public function options_page_description( $localized_heading_text = '' ) {

PS:WordPress技巧:手动还原到旧版本/更新到最新版

WordPress后台一般都可以直接一键升级,但是也存在一些情况导致无法自动升级,所以,倡萌简单说一下 wordpress 手动还原到旧版本 和 WordPress 手动更新到最新版的方法,其实,操作都是一样的,可以说是手动更新到任意版本。

WordPress 还原到旧版本

WordPress的更新是比较频繁的,但是某些主题和插件的更新没有跟上速度,所以当你更新wordpress以后,可能会发现和现在使用的主题或插件冲突,这时候,你可能会考虑将wordpress恢复到旧版本。

WordPress还原到旧版本,你可以全新安装旧版本,但是,这样一来,你原来的插件或主题的某些设置选项就会失效,所以,倡萌建议,手动操作恢复旧版本。

1.下载对应的 WordPress 旧版本

下载你目前使用的语言版本(即如果你使用官方中文版,就下载官方中文的旧版本,如果是英文原版,就下载英文旧版本)

2.更换 WordPress 程序文件

(1) 解压下载的旧版本,然后删除解压后的 wp-content 文件夹,使用 FTP 上传其他文件覆盖原来的文件。

注意:主机空间的 wp-content 文件夹里面有主题和插件等文件,根目录的 wp-config.php 里面是WordPress的配置文件,切记不要覆盖这些文件!!

(2) 访问 http://你的网址/wp-admin/ ,稍等会出现一个页面,提示你需要更新数据库,点击更新,就可以恢复到旧版本的wordpress。

WordPress 手动更新到最新版

wordpress更新到最新版的操作和上面是一样的,区别在于,你下载的版本是最新版即可。使用手动操作,就可以更换到任何版本(当然,如果版本差距太大,数据库结构都不一样,那就可能无法成功)

更多相关教程请访问 php编程从入门到精通全套视频教程

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

Simple Guide: Sending Email with PHP ScriptSimple Guide: Sending Email with PHP ScriptMay 12, 2025 am 12:02 AM

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP Performance: Identifying and Fixing BottlenecksPHP Performance: Identifying and Fixing BottlenecksMay 11, 2025 am 12:13 AM

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

Dependency Injection for PHP: a quick summaryDependency Injection for PHP: a quick summaryMay 11, 2025 am 12:09 AM

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

Increase PHP Performance: Caching Strategies & TechniquesIncrease PHP Performance: Caching Strategies & TechniquesMay 11, 2025 am 12:08 AM

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function