plugins – Shortcode in Gutenberg block or do_shortcode

I am wondering which differences there are between to put a shortcode in a Gutenberg block and using the do_shortcode function.

In particular, I wonder why the function

has_shortcode($post->post_content, $key)

doesn’t work if I use do_shortcode, but the same control is working correctly if I put a shortcode directly in the page using a Gutenberg block.

Is that a bug?

Thanks in advance.

plugins – How can I recreate my HTML page with custom grid layout (blocks spanning rows and columns) in WordPress?

I’m attempting to recreate my website on WordPress in the style of my old HTML code, and I don’t know how to recreate the grid of my old homepage here: http://selamawit.com/index-old.html

The problem is that while it’s a grid, the blocks span multiple rows and columns. Is there a (free) wordpress plugin I can use or is there a way to upload custom HTML code in order to recreate this layout?

document – How will you manage this step inside a wizard? Hard level: external plugins and valid signatures certificates needed

I’ll try to explain myself as best as I can:

I need to create a flow for sign documents in bulk. I mean, the user selects in a table a number of documents, and then the user applies the sign to all these documents.

How am I managing that? With a fullscreen wizard:

1 step: choose the sign type (without certification -easy, add only your name; and with certification -the complex way, using plugins and this stuff)

2 step review the selection of the documents (the list with the documents ready to be signed, nothing complex)

3 step result of the action (signed or error)

So, my problem is in the first step, with when you select the “sign with certificate” option because:

-First, we check (automatically) if there is a browser extension installed. If not, we should redirect to the extension install.

-Second, if we found the previous extension, we show a list of valid sign certificates previously installed by the user. So the user selects one and continues with the wizard. OR, if the user doesn’t have the signature certificate, we show the URLs to install one of the supported certificates

You can see here where all this should happen (low fidelity, sorry, haha):
Step 1 in the wizard

I’m not sure how to add these things inside a selection inside a step. I thought of adding a spinner ie: “checking certificates”. The result of this operation will be:

-No extension found: “You need to install X extension”
-Extension found, but no certificates found: “You need to add any of these valid sign certificates”
-Extension and certificates found: “Select a valid certificate”

In summary: spinner + required action.

spinner

spinner2

What do you think about this approach? I feel that this is a complex situation :/

PS: Sorry for my English

plugins – WordPress error: Options page Setting_ not found in the allowed options list

I don’t really know what to do now. :/ I tryed this:

add_action( 'admin_init', 'Setting_' );

And this is my strings and form setup:

function Setting_() {
    register_setting( 'options', 'My_plugin_header_logo' );
    register_setting( 'options', 'My_plugin_links_facebook' );
    register_setting( 'options', 'My_plugin_links_youtube' );
    register_setting( 'options', 'My_plugin_links_email' );
    register_setting( 'options', 'My_plugin_links_instagram' );
}

<form method="post" action="options.php">
 <input type="hidden" value="/wp-admin/options.php?page=my_plugin" name="_wp_http_referer">
   <p class="submit">
     <input id="submit" class="button button-primary" type="submit" name="submit" value="Save!"></p>
            </form>

Thnaks for any help!

plugins – How to properly enqueue jQuery knob on WordPress without conflict?

I’m building a plugin and I want to use jQuery Knob but it seems like using this method:

plugins_url( '/assets/js/jquery.knob.min.js, . . . . . 

Have conflicts with other plugins?

How to convert it like this?

wp_enqueue_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-mouse' );
wp_enqueue_script( 'jquery-ui-accordion' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'jquery-ui-slider' );

cms – Proper WordPress plugins to make one site for find cohabitant

ّI have seen this website (https://hamkhoone.com/) which is for finding cohabitant in Persian. Asked this question in wordpress.stackexchange.com site which detected as off topic so asked here.

I searched to find its CMS by google and don’ find the CMS on it:
enter image description here
but found some technology used on it by wappalyzer Chrome add-ones as you can see:
enter image description here

So i like to know by installing which plugin in WordPress site?

I have made one free WordPress example on this link which could be used to test and install suggested module on it and its user name is:
Admins user name is :admin
Password is :pass

Also it would be great if you share the WordPress bask up file for building similar site if you have tried on it.

Thanks.

cms – which plugins are proper to make one site for find cohabitant

ّI have seen this website (https://hamkhoone.com/) which is for finding cohabitant in Persian.

I searched to find its CMS by google and don’ find the CMS on it:
enter image description here
but found some technology used on it by wappalyzer Chrome add-ones as you can see:
enter image description here

So i like to know by installing which plugin in WordPress site?

I have made one free WordPress example on this link which could be used to test and install suggested module on it and its user name is:
Admins user name is :admin
Password is :pass

Also it would be great if you share the WordPress bask up file for building similar site if you have tried on it.

Thanks.

java – Spigot Plugin: Generic form of the plugin’s main clas

I have created a lot of spigot plugins in my “carreer” as a developer for a bunch of minecraft servers, but every time I start writing a new plugin, I basically “reinvent” the structure of my main plugin class, always so it fits best into what I consider to be a readable plugin, that also other developers that will work with these plugins after me can do so without getting a headache.

My most recent Main-Class looks like this:

package com.clanplugin;

import java.math.RoundingMode;
import java.util.HashMap;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.Scoreboard;

import com.earth2me.essentials.api.UserDoesNotExistException;

import com.clanplugin.commands.ClanCommand;
import com.clanplugin.commands.CommandRegistry;
import com.clanplugin.commands.implementation.AcceptCommand;
import com.clanplugin.commands.implementation.CreateCommand;
import com.clanplugin.commands.implementation.DeleteCommand;
import com.clanplugin.commands.implementation.DerankCommand;
import com.clanplugin.commands.implementation.InfoCommand;
import com.clanplugin.commands.implementation.InviteCommand;
import com.clanplugin.commands.implementation.InvitesCommand;
import com.clanplugin.commands.implementation.KickCommand;
import com.clanplugin.commands.implementation.LeaveCommand;
import com.clanplugin.commands.implementation.ListCommand;
import com.clanplugin.commands.implementation.MoneyCommand;
import com.clanplugin.commands.implementation.UprankCommand;
import com.clanplugin.commands.implementation.RejectCommand;
import com.clanplugin.commands.implementation.RevokeCommand;
import com.clanplugin.commands.implementation.SetCbCommand;
import com.clanplugin.commands.implementation.SetLeaderCommand;
import com.clanplugin.commands.implementation.SetNameCommand;
import com.clanplugin.commands.implementation.SetTagCommand;
import com.clanplugin.commands.implementation.ShowMaxClanMemberCommand;
import com.clanplugin.commands.implementation.ToggleMoneyCommand;
import com.clanplugin.commands.implementation.ToplistCommand;
import com.clanplugin.database.DatabaseConnector;
import com.clanplugin.database.DatabaseMethods;
import com.clanplugin.listener.PlayerConnectListener;
import com.clanplugin.listener.PlayerDisconnectListener;
import com.clanplugin.listener.TagSetterListener;
import com.clanplugin..manager.ClantagCache;
import com.clanplugin..manager.MessageManager;
import net.ess3.api.Economy;

public class Main extends JavaPlugin {
    
    private static CommandRegistry commandRegistry;
    
    private static Main plugin;
    public static HashMap<Player, Long> lastUseOfCommand = new HashMap<Player, Long>();

    public void onEnable() {
        plugin = this;

        saveDefaultConfig();
        registerCommands();
        registerListeners();
        loadDatabase();
        setDataUponReload();
    }

    public void onDisable() {
        DatabaseConnector.disconnect();

        System.out.println(MessageManager.disabledPluginConsoleMessage());
        plugin = null;
    }

    public static Main getInstance() {
        return plugin;
    }

    private void loadDatabase() {
        DatabaseConnector.connect();
        DatabaseMethods.initialiseDatabaseTables();
    }
    
    private void registerCommands() {
        this.getCommand("clan").setExecutor(new ClanCommand());
        
        commandRegistry = new CommandRegistry();
        
        commandRegistry.registerCommand(new ShowMaxClanMemberCommand());
        commandRegistry.registerCommand(new ListCommand());
        commandRegistry.registerCommand(new LeaveCommand());
        commandRegistry.registerCommand(new DeleteCommand());
        commandRegistry.registerCommand(new InvitesCommand());
        commandRegistry.registerCommand(new ToplistCommand());
        commandRegistry.registerCommand(new MoneyCommand());
        commandRegistry.registerCommand(new ToggleMoneyCommand());
        
        commandRegistry.registerCommand(new InviteCommand());
        commandRegistry.registerCommand(new AcceptCommand());
        commandRegistry.registerCommand(new RejectCommand());
        commandRegistry.registerCommand(new KickCommand());
        commandRegistry.registerCommand(new RevokeCommand());
        commandRegistry.registerCommand(new InfoCommand());
        commandRegistry.registerCommand(new SetTagCommand());
        commandRegistry.registerCommand(new SetNameCommand());
        commandRegistry.registerCommand(new SetLeaderCommand());
        commandRegistry.registerCommand(new UprankCommand());
        commandRegistry.registerCommand(new DerankCommand());
        commandRegistry.registerCommand(new SetCbCommand());

        commandRegistry.registerCommand(new CreateCommand());
        
        
    }
    
    public static CommandRegistry getCommandRegistry() {
        return commandRegistry;
    }
    
    private void registerListeners() {
        getServer().getPluginManager().registerEvents(new PlayerConnectListener(), this);
        getServer().getPluginManager().registerEvents(new PlayerDisconnectListener(), this);
        getServer().getPluginManager().registerEvents(new TagSetterListener(), this);
    }
    
    private void setDataUponReload() {
        for(Player player : Bukkit.getOnlinePlayers()) {
            if (DatabaseMethods.isPlayerInClan(player.getUniqueId())) {
                String playerUUID = DatabaseMethods.getPlayerUUID(player.getUniqueId());
                if (playerUUID.equals(player.getUniqueId().toString()))
                    DatabaseMethods.addPlayerName(player.getName(), player.getUniqueId());

                ClantagCache.put(player, DatabaseMethods.getClanTagByClanID(DatabaseMethods.getClanIDByPlayerUuid(player.getUniqueId())));
            }
            
            PlayerConnectListener.joinTimes.put(player, System.currentTimeMillis());
        }
    }
    
    @SuppressWarnings("deprecation")
    public static void updateScoreBoard(Player player) {
        try {

        if (player == null || player.getScoreboard() == null) {
            return;
        }

        Scoreboard board = player.getScoreboard();

        if (Bukkit.getOnlinePlayers().size() == 0) {

            board.getTeam("onlineplayers").setPrefix(" " + "0" + "/" + "" + Bukkit.getServer().getMaxPlayers());

        } else {

            board.getTeam("onlineplayers")
                    .setPrefix("" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getServer().getMaxPlayers());

        }

        try {
            board.getTeam("Kontostandcheck")
                    .setPrefix("" + Economy.getMoneyExact(player.getName()).setScale(2, RoundingMode.DOWN) + "$");
        } catch (IllegalStateException | IllegalArgumentException | UserDoesNotExistException e) {
            e.printStackTrace();
        }
        
        } catch (Exception e) {
            System.out.println("(ClanSystem) This is not the live environement or the scoreboard configuration has changed. Please review carefully.");
            e.printStackTrace();
        }

    }

}

It would be great to get some fresh idea’s what can be improved, maybe not only regarding the spigot-related stuff, but also maybe some general bad habits I might have. Thanks a lot in advance! If you have any questions to some functionality of the classes feel free to ask me about it in the comments 🙂

plugins – PHP Warning: file_get_contents(http://ip.googlescript.com… in Akismet3

I’m noticing this strange output in my Apache error logs for one of my WordPress websites.

PHP Warning: file_get_contents(http://ip.googlescript.com/66.205.156.117?api_key=e7d52430614c8319dbde9ba6cb49993e&amp;group=lib-js&amp;ua=Mozilla%252F4.0%2B%2528compatible%253B%2BMSIE%2B7.0%253B%2BWindows%2BNT%2B5.1%253B%2B.NET%2BCLR%2B2.0.50727%253B%2B.NET%2BCLR%2B3.0.04506.30%253B%2B.NET%2BCLR%2B3.0.04506.648%2529&amp;ip=66.205.156.117):
failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/moon/public_html/wp-content/plugins/Akismet3/Akismet3.php(23) :
runtime-created function(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code(1) : eval()’d code on line 113, referer: mywebsite.com

The error keeps repeating with different IP addresses after the googlescript.com/ part and is strangely being thrown by the Akismet plugin.

Is this a valid error or did my site get injected with some malicious code?

Thanks.

plugins – Cache WP remote_get HTTP Response using Transients

Using wp_remote_get keeps pinging the API on every page load. Which increase the server resource.

Is it possible to cache the response of the API store it using Transients and use it for next 5 minutes instead of keep pinging everytime?

And After 5 Minutes it should send request again and rewrite the stored value.

Here is my code for API Request. How to do this? I’m new to this. Help me please

function display_api_response() {
    $api_url = "https://randletter2020.herokuapp.com";
$response = wp_remote_get($api_url);
   if ( 200 === wp_remote_retrieve_response_code($response) ) {
        $body = wp_remote_retrieve_body($response);

        if ( 'a' === $body ) {
          echo 'A wins';
        }else {
          // Do something else.
        }
   }
}
add_action( 'init', 'display_api_response' );