lundi 23 mai 2016

WordPress 4.5.2: Uncaught ReferenceError: JQuery is not defined

Why my code is unable to run and brower's console is producing error "JQuery is not defined" even though I am en-queuing my JavaScript file into the plugin properly.

As per source code, JQuery Library file before is also importing before my JavaScript file.

Please take a look at the code below and let me know if I am doing something wrong:

File Path: wp-content/plugins/AjaxTest/AjaxTest.php

<?php
/*
Plugin Name: Ajax Test
Description: This is a Ajax Test plugin
Version: 1.0
*/

function add_ajax_file()
{
    wp_enqueue_script('ajax-test', plugins_url('/js/ajax.js', __FILE__), array('jquery'));
}

add_action('wp_enqueue_scripts', 'add_ajax_file');

File Path: wp-content/plugins/AjaxTest/js/ajax.js

JQuery(document).ready( function($){

    alert("Hello");
});

Error Message in Console:

Uncaught ReferenceError: JQuery is not defined
(anonymous function)    @   ajax.js?ver=4.5.2:1

Order of JavaScript files in source code after running above code into the browser:

<script type='text/javascript' src='http://localhost/wordpress1/wp-includes/js/jquery/jquery.js?ver=1.12.3'></script>
<script type='text/javascript' src='http://localhost/wordpress1/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.0'></script>
<script type='text/javascript' src='http://localhost/wordpress1/wp-content/plugins/AjaxTest/js/ajax.js?ver=4.5.2'></script>

As suggested on web from WordPress users with similar problem, I have already tired adding below code into the wp-config.php file but no luck

define('CONCATENATE_SCRIPTS', false);

I am using WordPress 4.5.2



via Chebli Mohamed

php post to a wordpress page

I am using wordpress and also insert_php plug in,

I want to post some input into another wordpress page

how can I do that?

code exmple

 <label for="name">text</label>
 <input id="phone" name="name_barak" type="text" />



via Chebli Mohamed

How do I go about creating an interactive file tree sidebar for Wordpress?

I can't seem to find a tutorials on how to create a custom file tree sidebar.

I want to emulate something like this for a list of products on a WordPress site.

Here's their HTML/CSS/JS code on this page.

I appreciate all your time and patience with me as I learn.

Also to let you know that I've tried to think this through, here's my STRATEGY: (feel free to make/add changes, these are just my train of thought, it may be wrong.)

  • build out the sidebars in separate PHP files. I would make one PHP sidebar file per product group. (so one for Citrus, one for Apples, ..., and one for the main products page)

  • call the appropriate sidebar PHP file into the appropriate product pages (great opportunity to use if...elseif I guess?). I may need to edit/create a template for the products pages.

  • add jQuery events so the sidebars expand/contract nicely



via Chebli Mohamed

Change behavior off the [_url] shortcode in contact form 7

I get some dynamic data in the URL that I want to send in my mails.

I use the short code [_url] resulting in this when sending the mails: http://ift.tt/1TFzvfV

I want to remove my domain name and only send the dynamic data when using [_url].

Anyone know how to make a function for this?



via Chebli Mohamed

How, send Form title (Contact form 7 - WP Plugin) in hidden input?

Its possible send contatc form name in email body?

[contact-form-7 id="86" title="Contact form 1"]

I try the Contact Form 7 Dynamic Text Extension — WordPress Plugins, but my form are in modal items, when i click in one, show me the modal, and change the url (add -> ?id=23) but the Dynamic Text Extension only accept this field in reload page not after.

Any help?

thanks



via Chebli Mohamed

CyberSource: How to Add Merchant Defined Data Field In Woocommerce

Is anyone coding Cyber Source with Woo Commerce using Merchant Defined Field fields ?



via Chebli Mohamed

Remove an action based on screen size in WordPress / WooCommerce

I've added an action via hook like this

function my_wc_function(){

//function codes here;
}

add_action('woocommerce_before_shop_loop_item_title','my_wc_function' );

Now in my theme options, users have the option to remove this function, so I got this done:

if (get_option('wc_remove_function') == 1) {
 remove_action('woocommerce_before_shop_loop_item_title','my_wc_function' );
}

Everything goes well but my concern this, I have another option in my Theme Options where they should be able to remove the same function only on mobile screens (say less than 1024px).

How I can achieve this?



via Chebli Mohamed