Posts Tagged with function

Displaying 1-7 of 7 results.
Resolved: WordPress How to remove cells(columns) from admin posts and pages table
posted by admin on April 21, 2017
altIn my wordpress website I have a few plugins, for example Yuzo Views, All in One Seo, etc, and they insert their columns to wordpress posts and pages editing tables, and I cant see general information in admin, like title, categories, tags etc. All fields very narrow, and I can't read information normally.Read more
Wiki: PHP file with array with key value from MySQL table columns generator functionwiki
posted by admin on April 18, 2017

public function array_from_table_generator($table, $id, $name, $prefix = 'tbl_'){
try
{
$sql = "SELECT t.".$id.", t.".$name." FROM ".$prefix.$table. " t ORDER BY t.id DESC";
// it is select query by mysql query or mysqli or by your way
/* $results = SELECT($sql); */ //change this field by your SELECT and
// end of select query
$string = '';
$filename = '../array/'.$table.'.php';

$string .= '<?php $array = '.PHP_EOL.'array('.PHP_EOL;
foreach($results as $key => $value){
$string .= chr(9).'"' . $value[$name] . '" => ' . $value[$id] . ','.PHP_EOL;
}
$string = rtrim(trim($string),',');
$string .= PHP_EOL.');';

$handle = fopen($filename, 'w');
fwrite($handle, $string);
fclose($handle);
echo $prefix.$table . " array generated successfully!
";
}catch ( Exception $e ) {
// send error message if you can
}
}

Usage:

array_from_table_generator('device', 'id', 'name');

Result:
device.php

<?php $array =
array(
"mobile device" => 2,
"desktop" => 1
);
Read more
Resolved: jQuery check if an HTML element is empty using
posted by admin on April 25, 2016
I'm trying to call a function only if an HTML element is empty, using jQuery.

Something like this:

if (isEmpty($('#element'))) {
// do something
}
Read more
Resolved: PHP date or datetime to Yesterday, Today
posted by admin on March 30, 2016
In my social website, I want to convert datetimes in format, like
Today
YesterdayRead more
Resolved: Wordpress call translation from po pot files in theme
posted by admin on March 16, 2016
I have po mo translation files, and I want to call my translation and use in my theme.
My theme name mytheme
I want to make my theme multilanguage, and make it by right way.
I created directory

mytheme/languages


I created my po mo files

mytheme/languages/ru_RU.po
mytheme/languages/ru_RU.mo


In wp-config.php file I add

define ('WPLANG', 'ru_RU');


In my header.php i call translation function

<?php echo __("Videos", "mytheme"); ?>


But it is not working, not translating.Read more
Not Resolved: Adding a Stylesheet to the Header
posted by admin on March 9, 2016
I want to include stylesheet files from functions.php like javascript file wp_register_script and wp_enqueue_script, but for css files in header.phpRead more
Resolved: WordPress deregister register enqueue script
posted by admin on March 9, 2016
Include JavaScript jQuery file to wordpress header, in functions.phpRead more