This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_plugin_basepath() { | |
$path = explode("/", plugin_dir_path(__FILE__)); | |
$basePath = explode("/", plugin_basename(__FILE__)); | |
$pathKey = array_search($basePath[0], $path); | |
$newArray = array_slice(array_filter($path), 0, $pathKey); | |
$fullBasePath = implode("/", $newArray); | |
return "/" . $fullBasePath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "Im about to pull the data.. Muh ... Shut your mouth"; | |
function pullTheData( $url, $county) { | |
$page = file_get_contents($url); | |
$doc = new DOMDocument(); | |
$doc->loadHTML($page); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* I'll write a function for this shortly | |
* | |
* */ | |
join(DIRECTORY_SEPARATOR,array( public_path(), "content", "source_files", "_translator", $new_name) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm -rf app/cache/* | |
rm -rf app/logs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp', 'the_function_name' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$image_url = /*place url here*/; | |
$upload_dir = wp_upload_dir(); | |
$image_data = file_get_contents($image_url); | |
<?php | |
$filename = basename($image_url); | |
if(wp_mkdir_p($upload_dir['path'])) | |
$file = $upload_dir['path'] . '/' . $filename; | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compare_distance($a,$b) | |
{ | |
if($a["details"]["distance"] == $b["details"]["distance"]) return 0; | |
return ($a["details"]["distance"] > $b["details"]["distance"]) ? 1 : -1; | |
} | |
usort($the_array, 'compare_distance'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Company Logo Image field | |
$att = my_update_attachment('user_photo', $post_id); | |
update_field('{field_key}', $att['attach_id'], $post_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* Upload Image to ACF Field | |
* From Frontend | |
* | |
*/ | |
//functions.php on theme folder | |
function my_update_attachment($f,$pid,$t='',$c='') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'admin_init', 'redirect_non_admin_users' ); | |
/** | |
* Redirect non-admin users to home page | |
* | |
* This function is attached to the 'admin_init' action hook. | |
*/ | |
function redirect_non_admin_users() { | |
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) { | |
wp_redirect( home_url() ); | |
exit; |
NewerOlder