Here my problem : i placed code to track event on analytics but the event are not sended to analytics... so i cant trak them.
here the code ( I use UNIVERSAL ANALYTICS )
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46738558-1', 'restaurant-mon-repos.fr');
ga('send', 'pageview');
</script>
Now the code inserted in my page.
Pls note that i track different event on different button for different action on the page.
$op .= '<ul class="cro_directionscal">
<li class="dir-label">' . __('To:','localize') . '</li>
<li><strong>' . stripslashes($postaddr) . '</strong></li>
<li class="dir-label">' . __('From:','localize') . '</li>
<li><input id="from-input" type=text value=""/></li>
<li><input id="to-input" type=hidden value="' . stripslashes($postaddr) . '"/></li>
<li><input id="driveclick" class="" onclick="Demo.getDirections();ga("send","event","Bouton","Clic","itineraire");" type=button value="' . __('Calculate:','localize') . '"/></li>
</ul>
<p>' . __('The driving directions are interactive. Click on any bold text for further explanation of the route.', 'localize' ) . '</p>
<div id="dir-container"></div>';
The second part of the code for an other tracking :
$op .= '<input type="submit" onClick="ga("send","event","bouton","clic","contact");" name="cro_form_sub" id="cro_form_sub" val="" . __("Submit","localize") . "">';
I dont know if the dashes are the prob...
Thank you for the help guys :)
For the first part of code with 2 functions on the OnClick i have just cut the part of Google Analytics, then i have insert it directly inside the Demo.getDirections() functions and it works.
For the second part i replaced the (") inside the ga() function with : (\') escaped simple quote. It works too ! :)
Related
I am trying to modify WordPress search form, so that after user enters the word in the search bar, that word would be translated and accordingly redirected into external link (for example google). I managed to do translation, redirection, but struggle to get search query in first place.
My code:
<form id="myform" name="myform" role="search" method="get" class="search-form" action="" target="_blank" >
<input type="text" id="SearchText" value="" name="SearchText" placeholder="<?php echo esc_attr($search_text) ;?>" >
<button onclick="go()" type="submit" id="searchsubmit" class="btnsearch"></button>
</form>
Then code for translation needs input for search query $XXXXXXXXXXXXX:
$url = 'https://www.googleapis.com/language/translate/v2?key=' . $apiKey . '&q=' . rawurlencode($XXXXXXXXXXXXX) . '&source=xx&target=en';
$str = $responseDecoded['data']['translations'][0]['translatedText'];
Then I have script that would take translated search query $str:
<script type="text/javascript">
function go() {
document.myform.action = "https://www.google.com/";
document.myform.SearchText.value = "<?php echo $str ?>";
...............
}
</script>
Everything works if I put any word instead $XXXXXXXXXXXXX, but the question what here needs to be entered so that it would take original search entry.
Thank you in advance for any help.
Do you need to receive a request passed in a get parameter? You can use jquery $.get https://api.jquery.com/jquery.get/
https://tr.wordpress.org/plugins/mobile-menu/
the plugin I am using
But my problem, Plugin search link;
mywebsite.com/?s=searchtitle
but what I want;
mywebsite.com/?s=searchtitle&post_type=product
I think it might be relevant code section;
$header_search = '<i class="mob-icon-search-6 mob-search-button"></i><i class="mob-icon-cancel mob-search-cancel-button"></i>';
$header_search .= '<div class="mobmenu-search-holder"><form class="mob-menu-search-form" action="" method="get">
<input type="text" name="s" class="mob-menu-search-field" placeholder="' . $titan->getOption( 'placeholder_text' ) . '" autofocus="">' . $search_button . '</form></div>';
I'm author of WP Mobile Menu. You can achieve this in several ways.
Try the solution in this topic.
https://wordpress.stackexchange.com/questions/223576/changing-a-themes-search-function-to-only-show-results-from-woocommerce
I'm trying to change the search functioanlity of a Wordpress website so it searches an external website instead. While I've been able to change the form action to use the external websites URL, I haven't been able to get the right search results. Here is the code I'm using:
<div class="et_search_outer">
<div class="container et_search_form_container">
<form role="search" method="get" class="et-search-form" action="https://www.premierkitchenandbathgallery.com/search.htm?S1=">
<?php
printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />',
esc_attr__( 'Search …', 'Divi' ),
get_search_query(),
esc_attr__( 'Search for:', 'Divi' )
);
?>
</form>
<span class="et_close_search_field"></span>
</div>
As noted above, I'm attempting to search Premiere Kitchen & Bath using https://www.premierkitchenandbathgallery.com/search.htm?S1=
However, every search seems to fail, showing:
"We're Sorry!
Your search for ""
did not match any results.."
So either the search term isn't being passed, or I'm not using the correct search string. Any suggestions? Here is the website I'm searching from, if you want to test - http://premierkitchen.solutioserver.com/ (use search bar in the menu)
Hi i am new to wordpress plugin development. i have issues with settings api. please help if you can.
Below is my problem.
The problem i am facing is the last record which is link it is updating in database but the title text is not updating in database.
So please help me find solution. Thank you.
function load_plugin() {
add_settings_section('plugin_main', '<h1>Ticker Settings</h1>', 'plugin_section_text', 'plugin');
add_settings_field('plugin_text_string', 'Title text', 'plugin_setting_string', 'plugin', 'plugin_main');
add_settings_field('post_title_link', 'Link', 'plugin_link_setting', 'plugin', 'plugin_main');
register_setting('plugin_options', 'plugin_options');
register_setting('post_title_link', 'post_title_link');
}
function plugin_section_text() {
echo '<p>Change your post ticker title and give link to.</p>';
}
function plugin_setting_string() {
echo "<input id='plugin_text_string' name='plugin_options' size='40'
type='text' value='" . get_option('plugin_options') . "' />";
}
function plugin_link_setting() {
echo "<input id='post_title_link' name='post_title_link' size='40'
type='text' value='" . get_option('post_title_link') . "' />";
}
add_action('admin_init', 'load_plugin');
function post_ticker_setting() {
?>
<div class="wrap">
<form action="options.php" method="post">
<?php
settings_fields('plugin_options');
settings_fields('post_title_link');
do_settings_sections('plugin');
?>
<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
</form>
</div>
<?php
}
You have to register all settings with register_setting (https://codex.wordpress.org/Function_Reference/add_settings_field). The register_setting lines you show don't correspond to your fields.
Also sections should be declared after the fields are registered (https://codex.wordpress.org/Function_Reference/register_setting)
In your code, the following lines
<?php
settings_fields('plugin_options');
settings_fields('post_title_link');
do_settings_sections('plugin');
?>
don't correspond to the declarations above:
add_settings_section('plugin_main', ...
add_settings_field('plugin_text_string', ...
add_settings_field('post_title_link', ...
Only the 'post_title_link' has the same name. Which is probably why it is the only one updating.
I have a shortcode/multiple feature image problem I'm hoping for a bit of help on.
My custom post type called rubow_medarbejder is displayed on a page with a shortcode. This works fine.
I need to add a second feature image. I've used the Multiple Featured Images plugin to do this. Problem is I can't get the image to display through my shortcode.
kd_mfi_get_featured_image_id() shows the id perfectly but when I type kd_mfi_get_featured_image() it brings this error message
Fatal error: Call to undefined function kd_mfi_get_featured_image() in /var/www/www.rubowarkitekter.dk/www/wp-content/plugins/Medarbejdere/medarbejdere_post_type_shortcode.php on line 22
The output part of my shortcode that provokes this error looks like this
$output .= '
<div id="medarbejder">
<div id="medarbejder-page-content-gray">' . kd_mfi_get_featured_image( 'hover-medarbejder-image-grayscale', 'rubow_medarbejder') . '</div>
<div id="medarbejder-page-content-img">' . get_the_post_thumbnail() . '</div>
<div id="medarbejder-page-content-navn">' . $meta['rubow_medarbejder_navn'][0] . '</div>
<div id="medarbejder-page-content-titel">' . $meta['rubow_medarbejder_titel'][0] . '</div>
<div id="medarbejder-page-content-telefon">' . $meta['rubow_medarbejder_telefon'][0] . '</div>
<div id="medarbejder-page-content-mail">' . get_the_content() . '</div>
</div>
';
Any hints to get this solved would be highly appreciated. Thanks!
Use Advanced Custom Fields plugin. Then add as much custom fields as you need. and use
echo get_field('my-other-featured-image');
To output.
You need to select image url and size in plugin to output like that.