Forcing Google Chrome POST/GET with JavaScript - php

I'm cross posting this question here. After a few days of it being unanswered, I realize the core question may be more of a web dev question, rather than Wordpress.
My original question: https://wordpress.stackexchange.com/questions/78037/wp-click-track-plugin-help
Details:
(Note: The wordpress plugin developer has admittedly given up on this plugin, so I'm on my own.)
Plugin location: http://wordpress.org/extend/plugins/wp-click-track/
Files in question within plugin: ajax.js and click-tracker.php
I've been using WP-Click-Track plugin for a few years now and it works great. The basis of the plugin is to find a href's within the post, and rewrite them with a little javascript. When the user clicks the link, the javascript reports to the plugin, which saves the link, the title and a count into a MySQL table. Pretty straight forward.
Even after a few years of undevelopment, the plugin continues to work great with Firefox and IE. It seems with the latest round of Chrome updates however, the plugin is not tracking them, unless the link (internal or external) contains target="_blank". This is fine for externally facing links, but I don't want to have internal links open up in a new window. That's annoying to the user.
I can see in the JavaScript that the plugin is asking browsers to do a POST for XMLHttpRequest, but after looking at my Apache logs, it appears as though Chrome is performing a GET for links that do not contain target="_blank".
This is where I think stackoverflow comes in: Is there a way (through another JavaScript applet?) to force Chrome to always do a POST so that those links are tracked?

Related

How to remove ad script from wordpress theme?

Every time I open my wordpress site, it has automatically generate pop ads of tradeadexchange.com . I have tried many possible solutions but none of them worked.
In head tag, this script is automatically injected.
Below calls are created. In chrome console>Network>
How should I remove this script tag in my code in wordpress. Site link -http://www.radhefurnishing.com
I think this is not an issue of wordpress there may be some extension in browser will cause this issue first of all try to check in different browser and different machine.
If that is still there then let me know i will help you using some coding stuff.

How to achieve immediate redirect to page before home page in Magento?

I am converting a Wordpress website to Magento. One aspect of this switch is achieving a Video Intro into the website. Currently it utilizes a Wordpress plugin which loads a website http://example.com/video-intro before http://example.com and after the video is finished playing the window is redirected to http://example.com.
I have purchased the pure PHP version of this plugin (documentation here: http://plugins.themestrike.com/videointro2/documentation-php/), but it does not seem to work with Magento. I cannot figure out why. The page http://example.com/video-intro works great, the redirect works great, but I cannot get http://example.com/video-intro to come up before anything else. *The plugin creator has responded as unable to provide any support for the script.
Off the top of my head, you could do 2 things:
use a php header function to redirect the home page to the page you wish - more info: http://php.net/manual/en/function.header.php
Alter your .htaccess file to always re-direct users to the video link.
However it is worth considering what do you do when considering repeat users who have already seen the video.

My Magnific popup is not working with quickphp

I'm totally new in website development and as my first experiment I'm working with website to replace my company's old site (if success).
Have done pritty much allready but I really want to have this popup image gallery to work with Magnific popup for the responsiveness.
I have setup a local server with QuickPhp for development as I don't have server for my website yet.
Eventhough my site is working when tested in CodePen but not on my Quickphp server.
I made sort of gallery site that contains images that is supposed to open to popup for larger view and to zoom closer if wanted. The popup itself will work but some of code doesn't work. In example:
-not showin close button.
-not closing popup when clicking background.
-no animation when popup opens.
this all works with the same code tested on the CodePen-site though.
Magnific popup JS and the CSS codes I copied from the Build tool(to the folder within the sites .php)
They are included to .php page with script. CSS in the head and the JS in the footer. JQuery is from google https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
For now I would need answears to theese Questions:
1. Is it possible that the problem is within the QuickPhp-server setup of mine? If It doesn't fully support jquery in local setup?
2. What else could be wrong?
If needed I can put the codes here later.
The problem was in the code allthough. I implemented the codes from the Maqnific website again and red the documentation over 5 times. I also noticed that the included stylesheet files needed to be linked from the website's root folder exactly as shown on the Macnific guide.
If anyone is having similar problem I suggest to keep on reading and searching. Taking a brake for day or two makes a differens in perspective too. Some time apart of the project helps to notice things that you might not have seen before. Especially checking the code for incorrections is a bitch.
Just yesterday I found a typo in my media query meta tag that was making my site not to change styling when viewport size changes. The typo was from 2 weeks ago. max-device-width was written as max-divice-width.

Most efficient way to convert a javascript call to php (related to Wordpress infinite scroll/social buttons issue)

Intro: I'm a newbie on both php and Javascript and have been trying to solve this issue for my site (another version of this issue here), but have had trouble putting into effect the answer by LocalPCguy.
(in short: the issue is that with infinite scroll activated, the social buttons work on the first posts that are loaded, but do not work for posts loaded subsequently).
I am working off of a WordPress them, and I've added my social buttons to an existing php file that generates most of the appearance of each post. I seem to be adding them to the right place because the buttons appear where I want them to on each post (only for the first ones on the page). Like the other two guys who posted about this problem, I am using digg digg as my social plugin.
Currently the code in the php file that generates the social buttons looks something like this:
<div class="sharing-button">
<?php dd_google1_generate('Compact (20px)') ?>
</div>
Like I said, this makes the button appear for the first posts that are loaded, but once the infinite scroll tries to load additional posts, the social button will not appear on those posts.
For now I have tried the following:
Add the code below just above or below (taken from the answer here), or inside my <div> containing the buttons in the php file.
if (typeof gapi !== "undefined") { gapi.plusone.go(); }
That didn't work I figured it was because a .php file would need some kind of signal to know that it needs to run a javascript operation. So I looked around and found a couple suggestions on how to do this, here and here. In neither case did I manage to get the buttons to appear appropriately. Below was what seemed like the least idiotic of those attempts:
<?php
echo '<script type="text/javascript">
if (typeof gapi !== "undefined") { gapi.plusone.go(); }';
echo '</script>';
?>
I also thought perhaps I needed to pass an argument into gapi.plusone.go(), and I tried passing my sharing-button <div> above, but that did not work either (php code inside a javascript script inside a php block... didn't have high hopes).
At this point I'm not sure what to do - I feel like the solution is probably quite simple but I'm completely stuck, having spent hours reading threads about javascript integration into php and the like.
Does anyone have an idea how I can go about applying that Javascript solution to my .php dependent Wordpress theme?
Many many thanks!
Short Answer: this is not possible.
Long Answer:
FIRST comes PHP, SECOND comes javascript.
The PHP "program" is run at the Server, which is you web provider's server. This server works out all the PHP stuff. After this one is finished, the files of the Website are sent to your computer. It contains, among other stuff, javascript.
And this javascript is only run on YOUR computer, the one you're looking at. Once your Browser loaded the page and starts running javscript, it's already too late to ask the Server for some more info.
There are techniques allowing for that (AJAX is the Keyword), but that's another question :-)
You need to initiate the javascript of the buttons for them to work since infinite scroll loads the next set of posts using ajax. One example I found but it only does it for facebook if the plugin uses FBML:
$(document).ajaxComplete(function(){
try{
FB.XFBML.parse();
}catch(ex){}
});
I'm using a custom implemented Like Box from facebook and infinite scroll and this works just fine.

Crawl Website using PHP

I've tried a bunch of techniques to crawl this url (see below), and for some reason the title comes back incorrect. If I look at the source of the page with firebug I can see the correct title tag, however, if I view the page source it's different.
Using several php techniques I get the same result. Digg is able to crawl the page and parse the correct title.
Here's the link: http://lifehacker.com/#!5772420/how-to-make-ios-more-like-android
The correct title is "How to Make Your iPhone (or Other iOS Device) More Like Android"
The parsed title is "Lifehacker, tips and downloads for getting things done"
Is this normal? How are they doing this? Is there a way to get the correct title?
That's because when you request it using PHP (without any JS support) you're getting the main page of lifehacker - which is lifehacker.com.
Lifehacker switched their CMS recently so that all requests go to an initial page and then everything after the hashbang is read by a JS script in the main page to figure out which page needs to be served. You need to modify your program to take this into account
EDIT
Have a gander at these links
http://code.google.com/web/ajaxcrawling/docs/getting-started.html
http://www.tbray.org/ongoing/When/201x/2011/02/09/Hash-Blecch
Found the answer:
http://lifehacker.com/#!5772420/how-to-make-ios-more-like-android
becomes:
http://lifehacker.com/?_escaped_fragment_=5772420/how-to-make-ios-more-like-android

Categories