Wednesday, April 27, 2016

WP - ACF frontend form showing "Are you sure you want to leave this page?" popup

This can happen after you submit your ACF frontend form via AJAX, and want to navigate away from the form page.

Solution:

Disable this popup by setting this flag:     acf.unload.active = false;

EXAMPLE:



<script type="text/javascript">
jQuery(document).ready(function() {

// setup fields
acf.do_action('append', jQuery('#popup-id'));
    acf.unload.active = false; //disables "Are you sure you want to leave this page box?"


//remove update post:
jQuery(".acf-form-submit").remove();

});



</script>


nano - copy entire line

If you are having problems copying full lines from logs using nano, you can enable nano word-wrapping by this command:

ALT + $

(usually maps to ALT + SHIFT + 4 in EU)

Some notes on debugging Android running applications

A few notes from recent troubles with debugging an app on Intex Helix 9 tablet...

0) Applications can malfunction for hardware-based reasons. For example, if your application
requires GSM card, which is not present in the device, app will crash.

1) Logcat is hardly accessible due to numerous driver problems with connecting adb to to the actual device (i.e. Intex Helix tablet drivers seem to be very hard to find)

2. ) If application wants to feature a monitoring app , it should ideally be completely separated from it. The reason is that malfunctioning Application Being Monitored will render the Monitoring App useless if ABM cannot be started.

3. ) There should be a semi-permanent error log on the phone / tablet which can be accessed offline if all other debugging attempts fail.

4. ) There is a particular type of silent error which very hard to debug ( i.e. user set to wrong category, which caues him/her receiving wrong information from service).

Monday, April 25, 2016

WP : if wp_delete_user() is not defined, check these 2 things

First,

you should call it in init event handler, or later

Second,

make sure you have this file included prior to call:


 require_once(ABSPATH.'wp-admin/includes/user.php' );
 $current_user = wp_get_current_user();



Friday, April 22, 2016

Too large images and not setting image size dimensions in CSS/HTML can destroy your web page

If you serve too big images (i.e. 2000x5000px), your mobile site could start showing white screen all the time. Also, flicker might seen as well.

Another potentital cause of flicker and white screen in mobile sites is not setting image dimensions in css or html (relying on max-width / max-height).

Transparent images can also cause choppy behavior of scrolling!7


CONFIRMED: Too large image dimensions, converted to smaller dimensions just by css / html attributes generate choppy scrolling experience, at least in chrome. Just replace with smaller images to solve it.

Regarding, choppy scroll of fixed elements in Chrome (a separate scrolling issue), this css can help a bit (apply to fixed element):

#header-wrap{

   backface-visibility: hidden;
   -webkit-transform:translateZ(0);
   transform:translateZ(0);
   -webkit-backface-visibility: hidden;

   background-repeat: no-repeat;
   will-change:transform, position;


}


Thursday, April 21, 2016

YouTube API v3 PHP supports resumable uploads

Pls do your own testing, but from my tests - resumable file uploads to YT seem to work with the PHP library. I think it could depend on the chunk size and the time between sequential attempts. I have successfully tried with chunk size of 50MB!
Write here if you need more info (I'm basically using the code as described on video.insert page in documentation for PHP library of YouTube API v3).

Plesk 12.0.18 running on Ubuntu 12.04 - > Internal Server Error in file Hieracrhical.php, on line 105 : No such file or directory

Plesk 12.0.18 running on Ubuntu 12.04 - > Internal Server Error in file Hieracrhical.php, on line 105 : No such file or directory

I think I have managed to fix this.

I was getting some kind of error (dangling symlink /dev/shm) while trying to restart psa/plesk.

It was fixed by adding this line to /etc/fstab:

shm   /dev/shm    tmpfs   defaults    0    0

After, that I ran:
mount /dev/shm


And running:
/usr/local/psa/bootstrapper/pp12.0.18-bootstrapper/bootstrapper.sh repair


After, that:


/etc/init.d/psa stopall && /etc/init.d/psa startall

It seems to be ok now. Cause? I don't know, maybe some kind of system upgrade caused this?

Wednesday, April 20, 2016

jQuery on mobile browsers causes intermittent white screens after the page has been fully loaded

Problem:
jQuery on mobile browsers causes intermittent white screens after the page has been fully loaded

Possible solutions:

1. Make sure you delete your cache completely (browser cache)

2. Make sure you don't have some issues with image sizes (for example, too small images trying to stretch too much)


If cache is not the problem, then the problem can be identified by removing parts of the page and re-testing.

Monday, April 18, 2016

Djikstra on ordering the thoughts in software design

Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one is willing to study in depth an aspect of one's subject matter in isolation for the sake of its own consistency, all the time knowing that one is occupying oneself only with one of the aspects. We know that a program must be correct and we can study it from that viewpoint only; we also know that it should be efficient and we can study its efficiency on another day, so to speak. In another mood we may ask ourselves whether, and if so: why, the program is desirable. But nothing is gained —on the contrary!— by tackling these various aspects simultaneously. It is what I sometimes have called "the separation of concerns", which, even if not perfectly possible, is yet the only available technique for effective ordering of one's thoughts, that I know of. This is what I mean by "focusing one's attention upon some aspect": it does not mean ignoring the other aspects, it is just doing justice to the fact that from this aspect's point of view, the other is irrelevant. It is being one- and multiple-track minded simultaneously.


More info on this:
https://en.wikipedia.org/wiki/Separation_of_concerns

Tuesday, April 12, 2016

git create branch from another branch


348down voteaccepted
If you like the method in the link you've posted, have a look at Git Flow.
It's a set of scripts he created for that workflow.
But to answer your question:
$ git checkout -b myFeature dev
Creates MyFeature branch off dev. Do your work and then
$ git commit -am "Your message"
Now merge your changes to dev without a fast-forward
$ git checkout dev
$ git merge --no-ff myFeature
edit
Now push changes to the server
$ git push origin dev
$ git push origin myFeature
And you'll see it how you want it.


http://stackoverflow.com/questions/4470523/git-create-a-branch-from-another-branch

git reset remote commits

git pull

git checkout [BRANCH_NAME]

git reset --hard [TARGET_COMMIT_SHA]

git push -f origin [BRANCH_NAME]

This should force deleting the commits newer than TARGET_COMMIT_SHA in the BRANCH_NAME.

PHP's mail can duplicate email messages if you use full email address in Reply-To and other header fields

If your mail() duplicates email messages, check if you have NAME SURNAME<email> format in use inside header fields (last parameter of mail()  ).


formvalidation.io - name field is necessary if you want your validation to work!

If you're using formvalidation.io plugin (http://formvalidation.io/) :

Make sure all your form  fields have a name attribute set, otherwise the plugin will fail to perform without any exception thrown!

If you are using bootstrap, marking your row with form-group class will also be necessary if you want formvalidation.io to properly color the invalid / valid inputs.

Thursday, April 7, 2016

Internal Server Error 500 - empty log file - error_reporting silently disabled!

Here's a recent problem I've encountered:

WP installation

WP_DEBUG enabled

display_errors and error_reporting and log_errors all enabled in php.ini and checked with phpinfo()

post.php generates Internal Server Error 500 if a single checkbox selected when "Publish post" is clicked

PHP/Apache error logs and WP's debug.log say nothing about the error


After pinpointing the exact line which causes the error, I've obtained error information by simply adding these two lines after the error generating line:

ini_set("display_errors",1);
error_reporting("E_ALL");

[problematic line]

die();

This immediately printed out the actual error and we're good to go!

So, the moral of this story:

Silently disabling error_reporting in WP or any other PHP code is a danger in disguise. Always bear in mind, that there's a possibility that someone turned of the error reporting inside a plugin or something. Very dangerous habit.

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...