Skip to content

Instantly share code, notes, and snippets.

@eto4detak
eto4detak / security hak.php
Created September 2, 2019 08:14
php security hak
<?php
$nonce = wp_create_nonce('my-nonce');
@eto4detak
eto4detak / proxi.php
Last active August 26, 2019 08:06
php proxi
<?php
///////////////////////////////////////////////////////////////////////////////////////////
/////// proxi
///////////////////////////////////////////////////////////////////////////////////////////
function proxi($url, $postdata = null, $cookiefile = 'tmp/cookie.txt'){
$proxy = '127.0.0.1:8888';
//$proxyauth = 'user:password';
$ch = curl_init($url);
@eto4detak
eto4detak / wp-php-cf7.php
Created August 4, 2019 18:12
wp php cf7
<?php
///////////////////////////////////////////////////////////////////////////////////////////
/////// добавить файл в cf7
///////////////////////////////////////////////////////////////////////////////////////////
add_filter( 'wpcf7_mail_components', 'filter_wpcf7_mail_components', 10, 3 );
function filter_wpcf7_mail_components( $components, $wpcf7_get_current_contact_form, $instance ) {
$components['attachments'][] = __DIR__. '/screenshot.png';
return $components;
@eto4detak
eto4detak / woo-product.php
Last active August 25, 2019 15:06
woo product
<?php
// get price
$custom_price = floatval($price) > 0 ? floatval($price) : 0;
$price = wc_price($custom_price);
$discount_woo = get_woocommerce_currency_symbol() .' '. $discount;
// create product
function stickertime_set_product_default()
{
global $post;
@eto4detak
eto4detak / wp-php-action24312.php
Last active September 4, 2019 14:44
wp php action2412
<?php
add_action( 'wp_head',[&$this, 'hook_css'] );
function hook_css(){
echo '<style>'.self::get_setting('map_styles').'</style>';
}
add_action( 'save_post_product', 'divie_save_post_product_for_urls' );
function divie_save_post_product_for_urls( $post_id ) {
@eto4detak
eto4detak / php-field.php
Last active August 30, 2019 11:09
php field
<?php
// checkbox
$val = get_option('compare_cars_templ');
$hide_comp_icon = !empty($val['no_comp_icon']) ? $val['no_comp_icon'] : false;
?>
<label><input type="checkbox" name="compare_cars_templ[no_comp_icon]" value="1" <?php checked( 1, $hide_comp_icon ) ?> /></label>
@eto4detak
eto4detak / php-text.php
Last active October 24, 2019 16:16
php text
<?php
$f = new NumberFormatter("ru", NumberFormatter::SPELLOUT);
echo $f->format(123456);
$content = "Статус посылки НП: </br>"
."Выдано в месте YYYY </br>"
."Ориентировочная доставка до Отделения ЧЧЧЧ dd--mm </br>"
."Ждите дополнительное уведомление при прибытии</br>";
document.addEventListener('DOMContentLoaded', function(){
EnviarCorreo();
});
function EnviarCorreo()
{
jQuery.ajax({
type: "POST",
url: 'coordinates.php',
data: {},
@eto4detak
eto4detak / wp php code.php
Last active August 22, 2019 19:11
wp php code
<?php
// добавить к запросу
function devise_number_displayed_posts($query) {
if (is_admin() || !$query->is_main_query()) {
return;
}
if (is_tax('category-catalogs')) {
$query->set('posts_per_page', 16);
return;
}
@eto4detak
eto4detak / woo php code.php
Last active June 5, 2019 08:26
woo php code
<?php
/*========================================================
* add field woo
========================================================*/
add_action('woocommerce_product_options_general_product_data', 'divie_woo_add_custom_fields_euro');
function divie_woo_add_custom_fields_euro()
{
global $product, $post;