dimanche 18 octobre 2015

Woocomerce - How To Link to Product Variation?

I am trying to find a way to have a link to a specific product variation.

I thought I had it solved with this plugin... http://ift.tt/1QJbCA6

However the I have 2 word product attribute names and can't seem to get it to work? I put _, -, & and + between the 2 words but not go.

Here is the doc...In my case I would have "color style" instead of just "color" http://ift.tt/1LYDO3Z http://ift.tt/1QJbCA8 (additional variations should be separated by '&') http://ift.tt/1LYDO41 (where the variation value is "Blue Green" with the space replaced by a '+')

Thanks!

MrMO



via Chebli Mohamed

Enqueue JavaScript into Wordpress plugin

I am trying to include JavaScript file in my plug-in. For testing I am calling a JavaScript function fun().

Here is my main plugin file code:

function wl_include_files() {
    wp_enqueue_script('wl_js', plugin_dir_path( __FILE__ ) . '/js/animate.js', array( 'jquery' ));
}

function wl_activate_plugin() {
    add_action('admin_enqueue_scripts', 'wl_include_files');
}

//
register_activation_hook(__FILE__, 'wl_activate_plugin');

function test() {
    $v = "<script>fun();</script>";
    echo $v;
}

//
add_action('admin_init', 'test');

Here is my JavaScript file code:

console.log('hi, file included properly.');

function fun() {
    alert("Hey, Someone calling me.");
}

I am getting following error in my console:

ReferenceError: fun is not defined

Can anybody tell what is the problem?



via Chebli Mohamed

wordpress adding plugin for ajax

i am new to wordress. trying to test creating a plugin to combine my js and ajax for a module. I did the following:

[Not sure if i need to add anything in admin-ajax.php.]

  1. created my new plugin under wp-content/pluging/test-plugin
  2. created 2 files: test.php and test.js
  3. test.php content as the following:

    /** * Plugin Name: Test */

    add_action("wp_ajax_my_test", "my_test");
    
    add_action("wp_ajax_nopriv_my_test", "my_test");
    
    function my_test()
    {
    echo "in ajax";
    }
    add_action( 'init', 'test_script_enqueuer' );
    
    
    function test_script_enqueuer() {
    
        wp_register_script( "test", WP_PLUGIN_URL.'/my_plugin/test.js', array('jquery') );
        wp_localize_script( 'test', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
    
        wp_enqueue_script( 'jquery' );
        wp_enqueue_script( 'test');
    }
    
    
  4. test.js code as the following:

    $(document).ready(function() {
    console.log('in js!'); jQuery.ajax( { type: 'POST', url: myAjax.ajaxurl, data: {
    action: 'my_test' }, dataType: 'json', cache: false, success: function(response) { alert(response); }, error: function(xhr, textStatus, errorThrown) { alert('error'); } }); });

Note that I can't even see the "in js!" message in my console.



via Chebli Mohamed

Grabbing information from different websites

Am currently working on a website ( http://durbeenoman.com ). I'm trying to use a plugin that grabs specific information from different websites and list them into my website. Any idea of a way or a plugin does such a job ?

Thanks



via Chebli Mohamed

vendredi 16 octobre 2015

Events Calendar WP plugin -Change view depending on Screen Width

We have a conflict somewhere on the Events calendar mobile view which prevents clicking on events in the month mobile view.

In the mean time I found the php code to change the view from month to list when mobile is detected from Modern Tribe.

   add_action( 'template_redirect', 'tec_mobile_template_redirect' );
   function tec_mobile_template_redirect() {
   if( tribe_is_month() && wp_is_mobile() ) {
    wp_redirect( tribe_get_listview_link() );
    exit();
    }

One solution proposed was to do this but change to List view when a screen is at tablet and mobile size as well besides just when it detects its viewed on a device. So we need to find a way to make it switch at media queries/breakpoints somehow.

Can anyone help me out with this?



via Chebli Mohamed

wordpress plugin - redirect

I have a simple wordpress with the following URL :

/
/about
/documentation
/article-1
/article-2
...
/article-18

All other URL gives 404, fine.

I would like a simple plugin that create the pages

/fr/
/fr/about
/fr/documentation
/fr/article-1
/fr/article-2
...
/fr/article-18

This new pages would display exactly the same content than the original ones. I don't want a 301 redirect because I want to keep the URL displayed. I just need /fr/documentation to return the same content that /documentation



via Chebli Mohamed

Admin Ajax not call in Media section in Wordpress

admin_ajax.php not call when i load media section in wordpress for different user role.

Please help me.



via Chebli Mohamed