Forum Replies Created

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter enriquerene

    (@enriquerene)

    Didn’t work too. I changed everything to call by absolute path but this enqueue doesn’t work.

    Thread Starter enriquerene

    (@enriquerene)

    Lemme point out some things:

    1) I’m developing in localhost;
    2) I’m using the twenty-sisxteen theme;
    3) The unique plugin installed is my own one;
    4) I went to Appearance >> Editor >> header.php and put wp_head();,
    do_action('wp_head');, together and separated there;

    With above items, nothing happened.
    I tried these:

    https://developer.www.ads-software.com/reference/functions/wp_enqueue_style/#source-code

    https://stackoverflow.com/questions/3472087/how-to-use-wp-enqueue-style-in-my-wordpress-theme

    In this last link, I tried the answer pointed as solution and the post bellow… nothing.

    My code is now as follow:

    In my main file

    add_action( ‘wp_head’, ‘easydm_add_link_tag_to_head’ );

    In my functions file:

    function easydm_add_link_tag_to_head() {
    wp_enqueue_style( ‘style’, plugins_url( ‘/css/style.css’, __FILE__ ), false, ‘1.0’, ‘all’ );
    }

    I tried many possibilities like ‘/wp-contents/plugins/css’, ‘/wp-contents/plugins/css/’, ‘wp-contents/plugins/css’, ‘/wp-contents/plugins/css/style.css’, ‘wordpress/wp-contents/plugins/css/style.css’…

    If makes clearer, the absolute path to my WP installation is ‘/var/www/wordpress’ and I access ‘localhost/wordpress’.

    Forum: Hacks
    In reply to: register_activation_hook
    Thread Starter enriquerene

    (@enriquerene)

    I forgot at the above post…I’d like to share a video what helped me to solve this:

    Forum: Hacks
    In reply to: register_activation_hook
    Thread Starter enriquerene

    (@enriquerene)

    Nice, you really help me to understand some stuff around this question. I’m doing some more tests but to my aim I got it.
    Your last answer assumes I’m developing in server, but I’m in localhost… after I’ll test in my own site and try publish to WP repositories.

    What I need that happens when someone activate my plugin is to create a directory to upload files. So in my main page of plugin I have

    define( ‘EASYDM_SETTINGS_PATH’, ‘settings/’ );

    require_once EASYDM_SETTINGS_PATH.’easydm-functions.php’;

    register_activation_hook( __FILE__, ‘easydm_activation’);

    Then inside my easydm_functions.php

    function easydm_activation() {
    $path = easydm_root_directory( EASYDM_PLUGIN_DIR );
    mkdir( $path, 0777, true );
    }

    Clearly my plugin prefix is easydm (Easy Downloader Manager) and mkdir is here “https://php.net/manual/pt_BR/function.mkdir.php”. (I’m saying this because some people who comes here may be novice in PHP too.)

    At the final of this discussion I’m still not sure why simple things like print_r() or echo don’t work. For me, it seems like register_activation_hook() just accept activate back-end stuff.

    Thanks for everything

    Forum: Hacks
    In reply to: register_activation_hook
    Thread Starter enriquerene

    (@enriquerene)

    I tried and nothing happens :/
    I tried four ways:

    1)

    add_action( __FILE__, ‘easydm_activation’ );
    – – – – – – – –
    function easydm_activation_hook() {
    error_log(‘Notice: Plugin Easy DM was activated’);
    }

    function easydm_activation() {
    register_activation_hook( __FILE__, ‘easydm_activation_hook’);
    }

    2)

    register_activation_hook( __FILE__, ‘easydm_activation’);
    – – – – – – – – – – – –
    function easydm_activation() {
    error_log(‘Notice: Plugin Easy DM was activated’);
    }

    3)

    add_action( __FILE__, ‘easydm_activation’ );
    – – – – – – – – –
    function easydm_activation() {
    error_log(‘Notice: Plugin Easy DM was activated’);
    }

    4)

    add_action( ‘activate_’.__FILE__, ‘easydm_activation’ );
    – – – – – – – – – –
    function easydm_activation_hook() {
    error_log(‘Notice: Plugin Easy DM was activated’);
    }

    function easydm_activation() {
    register_activation_hook( __FILE__, ‘easydm_activation_hook’);
    }

    In none of them, nothing happens. I open my wp-content directory and error log isn’t there (I tried hidden files too).
    My wp-config has:

    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_LOG’, true);
    define(‘SCRIPT_DEBUG’, true);
    define(‘SAVEQUERIES’, true);

    Forum: Hacks
    In reply to: register_activation_hook
    Thread Starter enriquerene

    (@enriquerene)

    ok. But I don’t understand how to use this in practice. I can’t use this when I’m coding, I don’t see any difference. I put some echos and JS alerts to tell me where and how this happens, but nothing happens.
    For example:

    define( ‘EASYDM__PLUGIN_URL’, plugin_dir_url( __FILE__ ) );

    function easydm_js_alert(){
    echo ‘<p>’.__FILE__.’
    ‘.__DIR__.'</p>’;
    }

    register_activation_hook( EASYDM__PLUGIN_URL, ‘easydm_js_alert’);

    This is in my ‘index’ plugin. Is it right? Is it working? How can I check these things?

Viewing 6 replies - 16 through 21 (of 21 total)