Posts

Showing posts with the label Wordpress

WordPress - How to create simple plugin with shortcode

Creating a simple WordPress plugin involves a few steps. Below is an example of a minimalistic WordPress plugin that adds a custom shortcode to display a greeting message. Step 1: Set Up Plugin Structure Create a new folder for your plugin in the "wp-content/plugins" directory. Let's call it "simple-greeting-plugin". Step 2: Create the Main Plugin File Inside your plugin folder (simple-greeting-plugin), create a main PHP file, e.g., "simple-greeting-plugin.php". Step 3: Add Plugin Information In your main PHP file, add the plugin information in the comment header. <?php /* Plugin Name: Simple Greeting Plugin Description: A simple WordPress plugin that adds a greeting shortcode. Version: 1.0 Author: Your Name */ Step 4: Add Greeting Shortcode Functionality Now, let's add the functionality to display a greeting message using a shortcode. Update your "simple-greeting-plugin.php" file as follows: <?php /* Plugin Name:...

Wordpress - REST API - How to set up roles

Wordpress REST API allows roles as array. But when you try to set roles as it is, it throws error. Correct list of roles: administrator editor author contributor subscriber customer As you see, all of these role names must be in lower case . For example: $user = WordpressAPI::createUser([ 'username' => 'test', 'email' => 'test@gmail.com', 'password' => '123456QQQ', 'roles' => ['subscriber'] ]); And you can add your own roles that you created in system.

Wordpress - How to log errors

On the first glance, it is easy to answer on this question. But, it is not. Yes, you can simply set WP_DEBUG constant to true, as many sites recommend. But, probably, it comes more problems than convenience. Because, it throws out all unnecessary, for your case, messages on the site, and, most likely, just fall apart whole layout. So, I recommend, do not switch on WP_DEBUG constant, and log what you want silently from users. For that: Set WP_DEBUG constant to true. We need to set up WP_DEBUG_DISPLAY constant to false, to hide errors from users. Write where you need error_log(). After that, you can check your logs and see error messages. If not, try to set up WP_DEBUG_LOG constant. There should be path to log file. wp-config.php file: define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', false ); define( 'WP_DEBUG_LOG', '/path/to/log/file.txt' ); // if needed

Wordpress - How to install plugins not using ftp

 Just add to wp-config.php file the next string: define ( 'FS_METHOD' , 'direct' ); And also make sure, that your wp-content folder has full access to create new folders by Wordpress system. 

Wordpress - miniOrange SSO using SAML 2.0 plugin - How to fix logout for FusionAuth

Reason issue : wrong NameID format < saml :NameID xmlns: saml ="urn:oasis:names:tc:SAML:2.0:assertion" > Fixing : use another NameID format < saml :NameID Format ="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" > It is placed in Utilities.php file on 59 line, the function called createLogoutRequest . There is another issue - all text is encrypted via ASCII codes. Easy to solve this problem: just copy this text and paste into echo with double quotes.  For example: echo " \74\77\x78\x6d\x6c\40\166\x65\x72\163\151\x6f\x6e\x3d\42\x31\x2e\x30\x22 \x20\x65\x6e\x63\157\x64\x69\x6e\147\x3d\42\x55\124\x46\x2d\x38\x22\x3f\76 " ; On the page it will be: <?xml version="1.0" encoding="UTF-8"?> So, after that, you can decode all text what you need to replace LogoutRequest.