Unable to get a simple plugin admin page to work

Even though I have years of software development experience, I am new to WP & PHP development, so please bear with me. After reading through the plugin manual, I started with a WP plugin boiler plate, made all the required field and name changes, added a custom capability, and, as a first real functionality, tried to add a simple admin interface for the plugin like so: <?php class Plugin_Name_Admin { // some code ommitted, the actual code uses my plugin's …
Category: Web

PHPUnit Plugin Integration Tests: Getting wordpress-tests-lib PHP into IDE (VS Code)

So I've managed to follow the instructions to get the "Plugin Integration Tests" set up using wp-cli and the install-wp-tests.sh script as described in the handbook article: https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/ After much hassle and debugging of a million things, I even have an example test running, yay! It's possible! Don't give up! My issue: The custom PHPUnit extensions for WP aren't picked up by my IDE. The /wordpress-tests-lib/ directory is deep in the bowels of my Mac, where install-wp-tests.sh installed it along …
Category: Web

How to set up VS Code for WP plugin/theme development in 2021?

I'm trying to improve my WP theme and plugin development workflow. VS Code is my editor/IDE of choice and I'm pretty with it in general. However, setting up VS Code with debugging, formatting, linting etc. for PHP, js and (s)css for WP ended up in quite a struggle. There are various good tutorials about how to achieve this, i.e. Linting and Formatting in Visual Studio Code for WordPress Setting Up PHP CodeSniffer in Visual Studio Code Sniffer, Linter, Pretty Printer …
Category: Web

How can I enable IDE integration (autocomplete) for WordPress test suite

When testing a theme or plugin, you can use WP-CLI to scaffold the test suite setup, wp scaffold plugin-test plugin. So is there a good way to integrate an editor/IDE (VS Code in my case) so that autocompletion (method signatures, etc) works within the tests? Since the test library is installed in /tmp/ the editor is not indexing those files and thus thinks classes and functions are missing.
Category: Web

Can any IDE (eg PHPStorm, VS Code) correctly show functions added via require get_template_directory() string results?

I would simply like to do some WordPress theme development using statements like require get_template_directory() . '/functions/base.php'; in my functions.php file. It seems IDEs do not know what to make of this function result and therefore do not map out [theme root]/functions/base.php as expected.
Category: Web

Is there a way to enforce the type of an object returned by a function that could return anything?

I am initializing a class where the constructor requires a WP_Post object. The object I would like to pass comes from get_queried_object() which could return almost anything. I am using is_a() to make sure I have the right type, which "works", but my IDE does not recognize that I have constrained the type. Is there a way to make it clear to the IDE that I have done my due diligence? I don't want to get in the habit of …
Topic: ide php Wordpress
Category: Web

Switching from editing on directly on remote server to PHPstorm local development?

I was recently told that my workflow would be improved if I switched from using emacs to edit the files on a staging server directly to using PHPstorm to make changes to my website. I am fairly lost on what I should do to set PHPstorm up properly as well as correctly cloning my website. I have set the website up using version control however it's not all of the content for the site, just the relevant files in the …
Category: Web

Wordpress / PhpStorm / XDebug and plugin_dir_path issues

I am trying to debug a wordpress plugin. I have XDebug working and I am able to use breakpoints and such. My issue is with the plugin_dir_url(__FILE__) call. It results to http://192.168.0.18/wordpress/wp-content/plugins/xdebug:/ It should be http://192.168.0.18/wordpress/wp-content/plugins/GFTH-BB-Update I am guessing it has something to do with the setup of the debugger in PHP Storm, but for the life of me I can't figure out what.
Category: Web

What is the best way to setup Wordpress for version control and PhpStorm while allowing updates

I have an active WordPress website that I would like to put under version control. Since I do keep pretty up to date on core and plugin updates I would think that those items should be best kept out of version control. I really wish that WordPress had a setup file like composer.json. That would make this immensely easier. I know that Drupal 8 is going that way, so good for them. But WordPress will probably not head down that …
Category: Web

PHPStorm variable warnings

I code in PHPStorm and include wp-admin and wp-include in my path, but get code inspection warnings related to undefined / unused variables. Should I be concerned about these? How would I go about satisfying a resolution to resolve the error (without just turning inspection off)
Topic: ide Wordpress
Category: Web

Is it a good idea to edit WordPress within Eclipse?

A friend and I are building a WordPress website. He has already customised a WordPress theme, and I can view the new site in an Internet explorer and edit it within the WordPress tool. He has sent me the source code. I need to do many modifications, and as a developer, I want to do that with Eclipse instead of the WordPress tool (is it a good idea?) Under Linux, I have already installed Eclipse, PDT, XAMPP, and can run …
Category: Web

Method 'post_title' not found in class.

I'm running some code through phpStorm and am getting an error: Method 'post_title' not found in class. at this line: echo $post->post_title(); Is that phpStorm getting things wrong or am I accessing post_title incorrectly?
Category: Web

Documentation for IDE's

I'm using IntelliJ but this question could apply to PhpStorm, Visual Studio, etc... Is there a good way to make the IDE aware of the Javascript functions that WordPress provides? Are there any Javascript stubs available like these Google Maps stubs? I'd like to have auto-completion available, parameter info, etc...
Category: Web

How do I Import an Exisiting WP Project into Aptana 3?

How do I import an existing Wordpress project into Aptana 3.04.2? I installed the Wordpress bundle in Aptana. I'm on a Mac running MAMP. My operating system is Leopard. My project is located at Sites->mysite. I clicked "Import Project" Clicked "General" Selected "Existing Projects into Workspace" Clicked "Next" Select root directory-- browsed to mysite (But, I got "No projects are found to import". How do I import my project (without messing it up)? Should I use "Create Project" instead? If …
Topic: ide Wordpress
Category: Web

Any guides on using WP SVN with IDE clients?

The documentation for dealing with official WP repository is exclusively about using command line. While I have no bias against that, I do have little experience with VCS and two (or three) different ones I will have to figure out and use in nearest future. So for now I wing it with VCS integration features in IDEs (NetBeans, PHPStorm). Which often leaves me confused on specifics and ways of doing things properly. Are there any good articles/posts/guides on using official …
Topic: ide svn Wordpress
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.