Custom posts type looping with custom taxonomies in WordPress
Loop any terms assigned to the custom post type along with custom taxonomy and display on the page
how to remove h2 formatting option from the wordpress classic editor
Below is the code to remove h2 option from wordpress classic editor
Password Strength Using Regular Expression IN PHP
<?php function password(){ $password = ‘user-pass’; //Password must be at least 8 characters in length. //Password must at least one upper case letter. //Password must at least one number. //Password must at least one special character. $uppercase = preg_match(‘@[A-Z]@’, $password); $lowercase = preg_match(‘@[a-z]@’, $password); $number = preg_match(‘@[0-9]@’, $password); $specialChars = preg_match(‘@[^w]@’, $password); if(!$uppercase || !$lowercase … Continue reading
Converting stdClass object to PHP array
#Converting stdClass object to PHP array The easiest way is to JSON-encode your object and then decode it back to an array: $array = json_decode(json_encode($stdclassobject), True); Or you can also traverse the object using loop, too: foreach ($stdclassobject as $value) $array[] = $value->post_id;
How to prepare a model to return json_encode data in Codeigniter framework
Here we are fetching data of the projects table and showing returning it in json format. public function projectData() { $result = array(); $data = $this->db->get_where(“projects”)->result(); foreach ($data as $row) { $result[] = array(“myid” => $row->id, “project_name” => $row->project_name, “description”->$row->description); } return json_encode($result); }
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /opencart-path/system/library/mail.php
Currently i was working in a open cart ecommerce solution and i came across this error: Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /opencart-path/system/library/mail.php on line 168 fsockopen(): unable to connect to :465 (php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, ornot known) in /opencart-path/system/library/mail.php on line 168Notice: Error: php_network_getaddresses: … Continue reading
20 Common Drupal Mistakes and How to Avoid
Drupal is undoubtedly one of the most flexible and powerful Content Management Systems available. So it really hurts us when someone criticizes Drupal because, most of the times Drupal is not at fault – what is wrong is the development and implementation. Below are list of common mistakes we should avoid.. Over coding: Custom code … Continue reading
Various Data Visualization Tools
A nice, informative and comprehensive gallery of data visualization tools.
AWeber Subscription Using CURL
AWeber Email Marketing Software creates profitable customer relationships for your business. Its email marketing tools like professional email signup forms & auto-responder services make it easy for you to build your email list and stay in touch with prospects. Few features of this service are: a. Manage Subscribers b. Auto Responders c. HTML Email Templates d. … Continue reading
useful jquery lazyload plugins
The Lazy plugin for jQuery load specified images after the page load itself and speed up your loading time through this. Images outside of the visible area will only get loaded when the user scrolls to them. jQuery.Lazy() jQueryLazyScrollLoading jQuery Lazy Load XT plugin bttrlazyloading jquery lazyload responsive lazy loader echo jscroll unveil least stalactite … Continue reading
how to remove index.php from codeigniter application url
In codeigniter applications we can see index.php in the url after the base_url. Below are steps how to remove index.php part from the url. We can do it by modifying .htaccess file and configuration file. Here is a example. Default url : http://www.mysite.com/index.php/contact-us We want to remove index.php part from this url as follows. After … Continue reading
Removing media button from word press editor
From WP 3.3, we can toggle the ‘Add Media’ button by using ‘media_buttons’ settings. $editor_settings = array(‘media_buttons’ => false); wp_editor($post_content, ‘content_id’, $editor_settings); More details can be found here.. http://codex.wordpress.org/Function_Reference/wp_editor Inserting images into multiple text boxes using wordpress default media manager javascript var uploadID = ”; /*setup the var*/ jQuery(‘.upload-button’).click(function() { uploadID = jQuery(this).prev(‘input’); /*grab the … Continue reading
Adding php location to environment variables path in windows
You can add a location to system Environment Variables PATH by following simple steps give below. For example i wanted to add my PHP directory path i.e. C:\wamp\bin\php\php5.3.13 to Environment Variables > Path value in Windows 7 Open Control Panel\System and Security\System in Windows Explorer or through Programs menu Click Advanced System Settings from left hand menu Click “Environment … Continue reading
Send Order Details To Admin Email in Opencart
In catalog/model/checkout/order.php v1.5.2.1+ find this code: Code: if ($this->config->get(‘config_alert_mail’)) { Above that place these code: $mail->setTo($this->config->get(‘config_email’)); $mail->send(); Author: santanu
A generic REST Service class Example
class RestFulService { private $supportedMethods; public function __construct($supportedMethods) { $this->supportedMethods = $supportedMethods; } public function handleRawRequest($_SERVER, $_GET, $_POST) { $url = $this->getFullUrl($_SERVER); $method = $_SERVER[‘REQUEST_METHOD’]; switch ($method) { case ‘GET’: case ‘HEAD’: $arguments = $_GET; break; case ‘POST’: $arguments = $_POST; break; case ‘PUT’: case ‘DELETE’: parse_str(file_get_contents(‘php://input’), $arguments); break; } $accept = $_SERVER[‘HTTP_ACCEPT’]; $this->handleRequest($url, $method, … Continue reading
Cross-domain AJAX with JSONP
Cross-domain AJAX with JSONP Anyone who develops Javascript long enough undoubtedly runs into difficulties involving the various security features all browser vendors implement. These security features are a good thing — they protect us from malicious users hijacking our browsing experience. But they can certainly cause some headaches. The security feature that presents the most … Continue reading
Php frameworks with list of features
PHP Framework PHP4 PHP5 MVC Multiple DB’s ORM DB Objects Templates Caching Validation Ajax Auth Module Modules EDP Akelos – ash.MVC – – – – – – CakePHP – – CodeIgniter – – – – – DIY – – – – – – eZ Components – – – – – – – Fusebox – – – … Continue reading
php ini settings
Php.ini setting for each variable: 1 > allow_call_time_pass_reference Boolean Whether to enable the ability to force arguments to be passed by reference at function call time. This method is deprecated and is likely to be unsupported in future versions of PHP/Zend. The encouraged method of specifying which arguments should be passed by reference is in the … Continue reading
Multiple constructors in php
The easiest way to use and understand multiple constructors: class A { function __construct() { $a = func_get_args(); $i = func_num_args(); if (method_exists($this,$f=’__construct’.$i)) { call_user_func_array(array($this,$f),$a); } } function __construct1($a1) { echo(‘__construct with 1 param called: ‘.$a1.PHP_EOL); } function __construct2($a1,$a2) { echo(‘__construct with 2 params called: ‘.$a1.’,’.$a2.PHP_EOL); } function __construct3($a1,$a2,$a3) { echo(‘__construct with 3 params called: … Continue reading
Perl functions A-Z
A AUTOLOAD abs – absolute value function accept – accept an incoming socket connect alarm – schedule a SIGALRM and atan2 – arctangent of Y/X in the range -PI to PI B BEGIN bind – binds an address to a socket binmode – prepare binary files for I/O bless – create an object break – break out of a “given” block C CHECK … Continue reading
Drupal 7 cheat sheet
page.tpl.php variables General Utility Variables $base_path The base URL path of the Drupal installation. $directory The directory the template is located $is_front TRUE if the current page is the front page. $logged_in TRUE if the user is registered and signed in. $is_admin TRUE if the user has permission to access administration pages. Site Identity $front_page … Continue reading
Open Web Messenger(php)
Mibew Messenger (also known as Open Web Messenger) is an open-source live support application written in PHP and MySQL. It enables one-on-one chat assistance in real-time directly from your website.
database operation in drupal 7
there are now different Drupal functions for each query type: SELECT – use db_query INSERT – use db_insert UPDATE – use db_update DELETE – use db_delete Note that you can also execute some of these queries with the drupal_write_record function, but I’ve been having problems getting that to work, so I’m using these functions instead. … Continue reading
Drupal 7 Theme Hook Suggestions
Theme hook suggestions: What’s a theme hook suggestion? It’s an alternate template (.tpl.php) file that you have created to override the base or original template file.. Custom Theme Hook Suggestions Custom suggestions beyond the ones listed below can be created. See the page Working with template suggestions. Default Theme Hook Suggestions in Core block–[region|[module|–delta]].tpl.php base template: block.tpl.phpTheme … Continue reading
display random background image or effect using php
sometimes we need to get random background image or effects which can be easily obtain using php. below is a small demonstration how to get the random values using php.. $input = array(“jswing”,”easeInQuad”,”easeOutQuad”,”easeInOutQuad”, “easeInCubic”,”easeOutCubic”,”easeInOutCubic”, “easeInQuart”,”easeOutQuart”,”easeInOutQuart”,”easeInSine”, “easeOutSine”,”easeInOutSine”,”easeInExpo”,”easeOutExpo”, “easeInOutExpo”,”easeInQuint”,”easeOutQuint”,”easeInOutQuint”, “easeInCirc”,”easeOutCirc”,”easeInOutCirc”,”easeInElastic”, “easeOutElastic”,”easeInOutElastic”,”easeInBack”,”easeOutBack”, “easeInOutBack”,”easeInBounce”,”easeOutBounce” ,”easeInOutBounce”); $rand_keys = array_rand($input); echo $input[$rand_keys]; if you need 2 random effects then it can … Continue reading
NATIVE CLIENT SIDE VALIDATION OF WEB FORMS
Validating forms has notoriously been a painful development experience. Implementing client side validation in a user friendly, developer friendly, and accessible way is hard. Before HTML5 there was no means of implementing validation natively; therefore, developers have resorted to a variety of JavaScript based solutions. To help ease the burden on developers, HTML5 introduced a … Continue reading
Got a tough coding task? Post it in bountify..
Got a tough coding task? Post it in bountify with a cash bounty ($1-250) to incentivize your fellow hackers. Painlessly Crowdsource Small Coding Tasks. Use Bountify for: Well-defined coding tasks Difficult, time consuming, and “tl;dr” programming questions “Make this code work” questions Questions that need attention ASAP Questions that should get answered on traditional forums but don’t … Continue reading
Generate PDF with PHP: FPDF, TCPDF, DOMPDF, ezPDF, FPDI and HTML2PDF
There are useful open source tools and libraries for generating images of various formats, csv(comma separated values), doc/docx and xls. Today, we are going to evaluate the options for PDF generation. Let’s have a look at some of the options available for generating PDF. FPDF: It is a simple class for generating PDF from pure PHP … Continue reading
mod_rewrite cheat sheet
mod_rewrite Tutorials http://httpd.apache.org/docs/current/rewrite/ http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/ http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/ mod_rewrite RewriteRule Flags C Chained with next rule CO=cookie Set specified cookie E=var:value Set environmental variable “var” to “value” F Forbidden (403 header) G Gone – no longer exists H=handler Set handler L Last – stop processing rules N Next – continue processing NC Case insensitive NE Do not escape … Continue reading
useful php functions/cheat sheet
PHP Array Functions array_diff (arr1, arr2 …) array_filter (arr, function) array_flip (arr) array_intersect (arr1, arr2 …) array_merge (arr1, arr2 …) array_pop (arr) array_push (arr, var1, var2 …) array_reverse (arr) array_search (needle, arr) array_walk (arr, function) count (count) in_array (needle, haystack) PHP String Functions crypt (str, salt) explode (sep, str) implode (glue, arr) nl2br (str) sprintf … Continue reading
who is query using php
function whois_query($domain) { // fix the domain name: $domain = strtolower(trim($domain)); $domain = preg_replace(‘/^http:\/\//i’, ”, $domain); $domain = preg_replace(‘/^www\./i’, ”, $domain); $domain = explode(‘/’, $domain); $domain = trim($domain[0]); // split the TLD from domain name $_domain = explode(‘.’, $domain); $lst = count($_domain)-1; $ext = $_domain[$lst]; // You find resources and lists // like these on … Continue reading
detect location by ip using php
function detect_city($ip) { $default = ‘UNKNOWN’; if (!is_string($ip) || strlen($ip) < 1 || $ip == ‘127.0.0.1’ || $ip == ‘localhost’) $ip = ‘8.8.8.8’; $curlopt_useragent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)’; $url = ‘http://ipinfodb.com/ip_locator.php?ip=’ . urlencode($ip); $ch = curl_init(); $curl_opt = array( CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HEADER => 0, … Continue reading
Sanitize user inputs using php
function cleaninput($input) { $search = array( ‘@<script[^>]*?>.*?</script>@si’, // Strip out javascript ‘@<[\/\!]*?[^<>]*?>@si’, // Strip out HTML tags ‘@<style[^>]*?>.*?</style>@siU’, // Strip style tags properly ‘@<![\s\S]*?–[ \t\n\r]*>@’ // Strip multi-line comments ); $output = preg_replace($search, ”, $input); return $output; } function sanitize($input) { if (is_array($input)) { foreach($input as $var=>$val) { $output[$var] = sanitize($val); } } else { … Continue reading
CSS3 Gradient Backgrounds
Linear Gradient (Top → Bottom) #linearBg2 { /* fallback */ background-color: #1a82f7; background: url(images/linear_bg_2.png); background-repeat: repeat-x; /* Safari 4-5, Chrome 1-9 */ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727)); /* Safari 5.1, Chrome 10+ */ background: -webkit-linear-gradient(top, #2F2727, #1a82f7); /* Firefox 3.6+ */ background: -moz-linear-gradient(top, #2F2727, #1a82f7); /* IE 10 */ background: -ms-linear-gradient(top, #2F2727, … Continue reading
10 Useful Frameworks To Develop Webapps for Touch Devices
In the last two years the rapid growth and diffusion of touch devices such as iOS or Android based platforms has forced developers and web designers to rethink the model of their own webapps for the new “touch experience” introduced by the iPhone in 2007. During this period several frameworks have been released to help … Continue reading
useful php,jquery scripts
jQuery PHP & MySQL inline editing Edit page content directly in the browser inline using jQuery AJAX requests jQuery Gallery Animated jQuery gallery with title and description Highlighting form inputs Highlight any input field using JavaScript jQuery JSON & PHP Create a simple product gallery using JSONP PHP and MySQL jQuery Tabs Simple tabs rendered … Continue reading
useful php snippets
Here’s a selection of really useful PHP code snippets that I find using on a weekly basis. You could use these as is or expand them as part of other applications or add them to a php class. Adjust server time If you have a server in a different timezone to you then you might … Continue reading
Swap images dynamically with jquery flash like zooming
<!–[if IE 6]> <style type=”text/css” media=”screen”> ul.thumb li img.hover { margin-top:15px; background:url(thumb_bg.gif) no-repeat center center; border: none; } ul.thumb li .title{color:#fff;width:185px;height:50px;margin:0;font-weight:900;background:url(title.gif) no-repeat center center;padding:17px 0 0 0;text-align:center;} </style> <![endif]–> <style type=”text/css”> body { font: Arial, Helvetica, sans-serif normal 10px; margin: 0; padding: 0; } * {margin: 0; padding: 0;} #page{ margin:0 auto; position:relative; width:850px; font-family:verdana; … Continue reading
Getting content,image,title of a page in wordpress calling function
if(!function_exists(‘getPageContent’)) { function getPageContent($pageId,$max_char) { if(!is_numeric($pageId)) { return; } global $wpdb; $nsquery = ‘SELECT DISTINCT * FROM ‘ . $wpdb->posts . ‘ WHERE ‘ . $wpdb->posts . ‘.ID=’ . $pageId; $post_data = $wpdb->get_results($nsquery); if(!empty($post_data)) { foreach($post_data as $post) { $text_out=nl2br($post->post_content); $text_out=str_replace(‘]]>’, ‘]]>’, $text_out); $text_out = strip_tags($text_out); return substr($text_out,0,$max_char); } } } } if(!function_exists(‘getPageTitle’)) { function … Continue reading
Useful Command List in Magento 2:
Below, you’ll find the list of all important Magento 2 SSH / CLI commands that you’ll often need when working on a project. Create an admin user using the CLI: php bin/magento admin:user:create –admin-user=’admin’ –admin-password=’admin123′ –admin-email=’admin@mysite.com’ –admin-firstname=’Json’ –admin-lastname=’Bourne’ Unlock admin user account using the CLI: php bin/magento admin:user:unlock username Setup upgrades using the CLI: php … Continue reading
AngularJS HTTP post to PHP and undefined output
Angularjs .post() defaults the Content-type header to application/json. This will overide form-encoded data, however it will not change data value to pass an appropriate query string, so PHP is not populating $_POST as you expect. Solution is use the default angularjs setting of application/json as header, read the raw input in PHP, and then deserialize the JSON. That can be achieved in … Continue reading
Top 10 WordPress Plugins(2018) – For Professional WordPress Websites
1.Nivo Slider (Free + Premium) Sliders and carousels are one of the major and effective elements that boost site’s engagement rate. To display multiple images and show case your works sliders and carousels are better tools. 2.W3 Total Cache (Free + Premium) Caching is one of the best ways to improve website performance. The general … Continue reading