Skip to content

Instantly share code, notes, and snippets.

View kenvilar's full-sized avatar
No coffee, no code ☕🚫

Ken Vilar kenvilar

No coffee, no code ☕🚫
View GitHub Profile
<?php
/*
http://stackoverflow.com/questions/12448134/social-share-links-with-custom-icons
http://petragregorova.com/articles/social-share-buttons-with-custom-icons
wp_enqueue_style('fontAwesome', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css', array(), '4.3.0', 'all');
use in template files:: <?php echo do_shortcode('[social_sharing]') ; ?>
*/
@kenvilar
kenvilar / blog-cards-archive-3-grid-layout.php
Last active February 18, 2026 04:50
Wordpress: Blog Cards Archive (3 Grid Layout)
<?php
/**
* Blog Cards (with category filter, search, and load more)
* Usage: [cogcpa_blog_cards]
*
* Optional params (if you want different counts):
* [cogcpa_blog_cards initial="12" more="6"]
*/
function cogcpamedia_render_blog_card( $post_id, $image_size = 'large' ) {
@kenvilar
kenvilar / jquery.textroll.js
Created February 26, 2024 15:58
jquery.textroll.js
/**
* jQuery textroll v0.1
* jquery plugin for rolling text in sentence.
*
* Copyright 2012 Alexandre Kirillov
* alexandre.kirillov@gmail.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
@kenvilar
kenvilar / index.php
Last active May 23, 2020 09:55
Password Generator with non special characters
<?php
function generate_password($length = 12)
{
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' . '0123456789`-=~!@#$%^&*()_+,./<>?;:[]{}|';
$str = '';
$max = strlen($chars) - 1;
for ($i = 0; $i < $length; $i++) {
@kenvilar
kenvilar / index.php
Created May 23, 2020 09:28
Create Cpanel database through PHP script
<?php
$database_name = "dbname"; // without prefix
$database_user = $database_name; // database name and database username are both similar, change the value if you want
$database_pass = "random_password";
$cpanel_username = "my_cpanel_username";
$cpanel_pass = "my_cpanel_password";
$cpanel_theme = "paper_lantern"; // change this to "x3" if you don't have paper_lantern yet
function createDb($cpanel_theme, $cPanelUser, $cPanelPass, $dbName)
@kenvilar
kenvilar / createSubDomain.php
Created May 21, 2020 14:04
How to create subdomain dynamically without going cPanel using PHP
<?php
$subDomain = "subdomain";
$cPanelUser = 'cpanel_username';
$cPanelPass = 'cpanel_password';
$rootDomain = 'rootdomain';
// $buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain;
@kenvilar
kenvilar / code-snippet.php
Created February 6, 2019 12:55
Code Snippet of ManageWP to delete the twentynineteen theme in all sites
<?php
echo exec('whoami') . PHP_EOL;
// removing directory using rmdir()
$twentynineteendir = './wp-content/themes/twentynineteen';
$twentynineteen = `ls -la $twentynineteendir`;
if ( gettype($twentynineteen) === 'NULL' ) {
echo $twentynineteendir . " folder does not exists";
} else {
$rmdir = `rmdir ./wp-content/themes/twentynineteen`;
@kenvilar
kenvilar / .htaccess
Created April 17, 2018 13:06
Laravel .env Security Practices
# Disable index view
Options -Indexes
# Hide a specific file
<Files .env>
Order allow,deny
Deny from all
</Files>
@kenvilar
kenvilar / serverCodes.md
Created April 3, 2018 02:31
status codes

1xx: Information

Code Message Description
100 Continue The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Checkpoint Used in the resumable requests proposal to resume aborted PUT or POST requests

2xx: Successful

Code Message Description
@kenvilar
kenvilar / functions.php
Last active March 28, 2018 17:05
Wordpress AJAX Search
function recipe_search() {
$recipe_name = $_POST['recipe_name_val'];
$args = array(
'post_type' => array('recipe'),
'posts_per_page' => -1,
's' => $recipe_name
);
$posts = get_posts($args);