Skip to content

Instantly share code, notes, and snippets.

View kkarpieszuk's full-sized avatar

Konrad Karpieszuk kkarpieszuk

View GitHub Profile
<?php
// action is icl_register_admin_string and we want to handle it only for administrators
add_action( 'wp_ajax_icl_register_admin_string', 'icl_register_admin_string' );
add_action( 'wp_ajax_nopriv_icl_register_admin_string', 'icl_register_admin_string_nopriv' );
function icl_register_admin_string() {
// add code for http://codex.wordpress.org/Function_Reference/check_ajax_referer
if (curent_user_can('manage_options')) {
/**
* Changes array of items into string of items, separated by comma and sql-escaped
*
* @see https://coderwall.com/p/zepnaw
*
* @global wpdb $wpdb
* @param array $items items to be joined into string
* @param string $format %s or %d
* @return string Items separated by comma and sql-escaped
*/
protected function save( $dest, $html_templates ) {
$order_language = get_post_meta( $this->order->id, 'wpml_language', true );
$user_id = get_current_user_id();
$temp_language = null;
if (is_numeric($user_id)) {
$temp_language = get_user_meta( $user_id, 'icl_admin_language_for_edit', true );
update_user_meta($user_id, 'icl_admin_language_for_edit', $order_language);
do_action('wpml_switch_language', $order_language);
}
#!/usr/bin/python
# 1. create file install.py inside of this directory with .sql files
# 2. place it inside of file (adjust dbname dbuser and dbpass)
# 3. run python install.py
from os import listdir
from os.path import isfile, join
from os import system
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
wp_url = "http://localhost/qatests/"
wp_admin_url = wp_url + "wp-admin/"
wp_login_url = wp_url + "wp-login.php"
wp_plugins_url = wp_admin_url + "plugins.php"
/**
* The following styles get applied inside the editor only.
*
* Replace them with your own styles or remove the file completely.
*/
.wp-block-syntax-block-syntax-highliter {
border: 1px dotted #f00;
}
@kkarpieszuk
kkarpieszuk / functions.php
Created February 20, 2020 07:09
Replace WordPress word with link to the site in WordPress post content
<?php
// add code below to functions.php file of your theme
add_filter( 'the_content', function( $content ) {
if ( ! is_admin() ) {
$content = str_replace( 'WordPress', '<a href="https://wordpress.org">WordPress</a>', $content );
}
return $content;
} );
@kkarpieszuk
kkarpieszuk / functions.php
Last active April 6, 2020 07:58
How to fix malformed data in ACF field, caused by ACFML 1.6.0
// edit: if you are using wp-cli, you can try to use this plugin https://github.com/OnTheGoSystems/acfml_fixer
// otherwise, please follow instructions below
// PLEASE READ ALL COMMENTS BEFORE RUNNING THIS SNIPPET
// ALSO THE COMMENTS AT THE END OF THIS SNIPPET
//
// CREATE DATABASE BACKUP!
//
// update ACFML to the version 1.6.1, you can find it in wpml.org > my account > downloads
// add the whole snippet to your functions.php in theme directory and visit any page of your blog/site
/**/_xdc_._sixyrm && _xdc_._sixyrm( {
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "Swansea",
"short_name" : "Swansea",
"types" : [ "locality", "political" ]
},
{
diff --git a/wpforms/src/Admin/Payments/Views/Overview/Page.php b/wpforms/src/Admin/Payments/Views/Overview/Page.php
index a1879f46d..534dfd825 100644
--- a/wpforms/src/Admin/Payments/Views/Overview/Page.php
+++ b/wpforms/src/Admin/Payments/Views/Overview/Page.php
@@ -118,7 +118,7 @@ class Page implements PaymentsViewsInterface {
static $mode;
- if ( ValueValidator::is_valid_mode( $mode ) ) {
+ if ( ValueValidator::is_valid( $mode, 'mode' ) ) {