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 add_script_in_plugin_1(){ | |
wp_enqueue_script('custom-script', plugins_url( '/js/newscript.js', __FILE__ ), array('jquery')); | |
wp_enqueue_style( 'style-name', plugins_url( '/css/custom.css', __FILE__ ) ); | |
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
<script> | |
//контроль цели отправки формы | |
(function ($) { | |
$('.menu-item-34927 a').click(function(){ | |
yaCounter27903495.reachGoal('help_click'); | |
}); | |
}(jQuery)); | |
</script> | |
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 | |
$key_oer = '???'; // тут указываем ключ API | |
$url_api_oer = 'https://openexchangerates.org/api/latest.json?app_id=' . $key_oer; | |
$response = wp_remote_get($url_api_oer); | |
$data_exchange = json_decode( wp_remote_retrieve_body( $response ) ); | |
var_dump($data_exchange); // вернет объект с данными, которые можно далее использовать в коде |
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 save_data_to_file(){ | |
// output headers so that the file is downloaded rather than displayed | |
header('Content-Type: text/csv; charset=utf-8'); | |
header('Content-Disposition: attachment; filename=data.csv'); | |
$output = fopen('php://output', 'w'); | |
$data = array( |
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
'.text.html': | |
'Plugin': | |
'prefix': 'plugin-wp' | |
'body': '<?php\n/*\nPlugin Name: $1\nVersion: ${2:0.1}\nPlugin URI: ${TM_PLUGIN_BASE}$3\nDescription: $4\nAuthor: ${TM_NAME}\nAuthor URI: ${TM_HOMEPAGE}\n*/\n\n$5\n\n\n?>\n' | |
'Readme.txt': | |
'prefix': 'readme-wp-plugin' | |
'body': '=== ${1:Plugin Name} ===\nContributors: ${TM_WP_LOGIN}\nDonate link: ${TM_HOMEPAGE}\nTags: ${2:tag, tag}\nRequires at least: ${3:2.5}\nTested up to: ${4:2.8}\nStable tag: ${5:0.1}\n\n${6:Short description}\n\n== Description ==\n\n${7:Short description}\n\n== Installation ==\n\n1. Upload the \\`${8:plugin}\\` folder to the \\`/wp-content/plugins/\\` directory\n1. Activate the plugin through the \'Plugins\' menu in WordPress\n1. $9\n\n== Changelog ==\n\n= $5 =\n* Initial release.' |
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 | |
function wpc37174_special_nav_class($classes, $item){ | |
if( is_single() && $item->title == "Blog"){ | |
$classes[] = "special-class"; | |
} | |
return $classes; |
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 | |
/** | |
* Add Endpoint for URL Callback OAuth2 | |
*/ | |
class HAWP_Endpoint_Callback { | |
function __construct() { | |
add_action( 'init', array($this, 'add_endpoint') ); | |
add_action( 'wp_loaded', array($this, 'flush_rewrite_rules_hack') ); |
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 | |
function wpcraft_zip_gzip_mime_types ( $mimes ) { | |
$existing_mimes['zip'] = 'application/zip'; | |
$existing_mimes['gz'] = 'application/x-gzip'; | |
return $mimes; | |
} | |
add_filter('upload_mimes', 'wpcraft_zip_gzip_mime_types'); | |
?> |
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 | |
/** | |
* Generate login for new WP user | |
* | |
* return string uniq login | |
*/ | |
function generate_new_userlogin(){ | |
$users_ids = get_users('fields=ID&number=3&orderby=registered&order=DESC'); | |
$last_id = max($users_ids); |
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
private function wooms_nonce_check($nonce = ''){ | |
if(empty($nonce)){ | |
return false; | |
} | |
if($nonce == get_transient('wooms_nonce')){ | |
delete_transient('wooms_nonce'); | |
return true; | |
} else { | |
return false; |