Skip to content

Instantly share code, notes, and snippets.

View gdarko's full-sized avatar
Crunching code, one line at a time.

Darko Gjorgjijoski gdarko

Crunching code, one line at a time.
  • Self-employed
  • The Internet
  • 10:41 (UTC +02:00)
View GitHub Profile
@gdarko
gdarko / class-dg-image-import.php
Created December 26, 2018 09:43
Import images to media library from specific directory.
<?php
/**
* Class DG_Image_Import
* @author Darko Gjorgjijoski <dg@darkog.com>
* @license GPLv2
* @copyright 2019
*
* Handles import of images from a specific subfolder of your root site dir (eg public_html/your_data_dir) to WordPress media library.
* Has basic lock/unlock functionality to avoid colisions.
@gdarko
gdarko / gravityforms_username.php
Last active April 26, 2019 16:39
GravityForms + User Registrations plugin: Use first name and last name in the form to generate username out of both. Append number if the username exists.
<?php
/**
* Check if there is still pending registration for specific username
* @param $username
*
* @return bool
*/
function dg_check_pending_registration($username) {
global $wpdb;
$table = $wpdb->prefix . 'signups';
@gdarko
gdarko / class-email-post-authors.php
Last active July 15, 2019 20:46
Email Blog Authors Example
<?php
if ( class_exists( 'WP_Batch' ) ) {
/**
* Class Email_Blog_Authors
*/
class Email_Post_Authors extends WP_Batch {
/**
* Unique identifier of each batch
@gdarko
gdarko / str_contains.php
Last active May 2, 2024 02:43
str_contains() was introduced in PHP8. This is a polyfill for PHP7 or lower.
<?php
if (!function_exists('str_contains')) {
/**
* Check if substring is contained in string
*
* @param $haystack
* @param $needle
*
* @return bool
*/
@gdarko
gdarko / change-privacy.php
Created March 23, 2020 23:05
Change the view privacy for the new Vimeo uploads from WP Vimeo Videos PRO plugin
<?php
/**
* Change the default view privacy in WP Vimeo Videos PRO
* This only applies if you have Vimeo Plus, Vimeo PRO, Vimeo Business (or higher level) account.
* @url https://developer.vimeo.com/api/guides/videos/interact#set-vimeo-privacy
*/
function dgv_default_privacy_1821210($privacy) {
$privacy = 'unlisted';
return $privacy;
@gdarko
gdarko / hide-upload-options.php
Created June 5, 2020 22:01
Hide upload options on WP Vimeo Videos
<?php
/**
* Hide Upload options on WP Vimeo Videos
* @return void
*/
function wvv_disable_upload_options() {
echo '<style>.dgv-vimeo-form-row label {display:none !important;}</style>';
}
add_action('admin_head', 'wvv_disable_upload_options');
@gdarko
gdarko / hide-search-option.php
Created June 19, 2020 10:09
Hide search option in Wp Vimeo Videos upload block
<?php
/**
* Hide search option in WP Vimeo Videos
* @return void
*/
function wvv_disable_upload_options() {
echo '<style>.dgv-vimeo-upload-form > .dgv-vimeo-form-row > label:last-child { display: none !important;}</style>';
}
add_action('admin_head', 'wvv_disable_search_option');
@gdarko
gdarko / hide-embed-privacy.php
Created June 19, 2020 10:22
Hide embed privacy in WP Vimeo Videos
<?php
/**
* Hide embed privacy in WP Vimeo Videos
* @return void
*/
function wvv_edit_hide_embed_privacy() {
if(isset($_GET['page']) && $_GET['page'] === 'dgv-library') {
echo '<style>#dgv-video-save-embed-privacy {display:none !important;}</style>';
}
@gdarko
gdarko / prices.html
Created July 9, 2020 21:36
Metal Prices Widget
<div class="gs-stats silverprice">
<img src="http://www.kitconet.com/images/sp_en_6.gif">
</div>  
@gdarko
gdarko / wp-vimeo-videos-examples.php
Last active December 22, 2020 00:08
How to use the Vimeo videos API
<?php
# Example 1 - Upload local video
$api = new WP_DGV_Api_Helper();
$path = '/home/user/video.mp4';
$params = array(
'name' => 'Cool Video',
'description' => 'Some description',
);