Wordpress Tips And Troubleshooting

Go to appearence to theme editor find function.php

add_action('rest_api_init', 'register_rest_images' );
function register_rest_images(){
    register_rest_field( array('post'),
        'fimg_url',
        array(
            'get_callback'    => 'get_rest_featured_image',
            'update_callback' => null,
            'schema'          => null,
        )
    );
}
function get_rest_featured_image( $object, $field_name, $request ) {
    if( $object['featured_media'] ){
        $img = wp_get_attachment_image_src( $object['featured_media'], 'app-thumb' );
        return $img[0];
    }
    return false;
}

301 redirect using wordpress plugin

I've had an issue when I need to change domain but I want to keep my links and don't want to duplicate content (been there pinguin) So I've tried few plugins but it seems that the only plugins that works for me is a plugin call redirection.

Fixing insert media HTTP error Wordpress

Make an .htaccess file in wp-admin, paste this line :

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

define('WP_MEMORY_LIMIT', '64MB');

Adding Table on Activate Plugins

function lapakAddTable()
{
    global $wpdb;
    $table_name = $wpdb->prefix . 'registration';

    $sql = "CREATE TABLE `$table_name` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `name` varchar(220) DEFAULT NULL,
        PRIMARY KEY(id)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
    if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
    }
}
register_activation_hook(__FILE__, 'lapakAddTable');

Removing Table on Deactivate plugins

tryed using dbDelta($sql) turns out it doesn't support DROP TABLE

function lapakRemoveTable()
{
    global $wpdb;
    $table_name = $wpdb->prefix . 'registration';
    $sql = "DROP TABLE IF EXISTS `$table_name`";
    if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
        $wpdb->query($sql);
    }
}

register_deactivation_hook(__FILE__, 'lapakRemoveTable');

Function on uninstalling plugins

register_uninstall_hook(__FILE__, 'Hooks::uninstall');

access level to ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document::get_create_url() must be public

it show "there has been a critical error on your website" after enabling the debug it shows the error on top. The fix is to update the elementor.

Subscribe to You Live What You Learn

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe