Skip to content

Instantly share code, notes, and snippets.

@max-kk
max-kk / g.php
Last active September 2, 2015 14:30 — forked from anonymous/g.php
<?php
add_filter('fv/public/upload_form/label', 'custom_filter_public_upload_form_label', 1, 4);
function custom_filter_public_upload_form_label ($label, $field, $c, $contest) {
$lang = get_bloginfo( 'language' ); // 'ru-RU' - example
if ( trim($label) = "Titre de la vidéo" ) {
switch($lang) {
'be-BE':
<?php
function test_get_def_transal() {
// возвращаем массив, со значениями по умолчанию
return array(
'text_1' => 'This is text 1!',
'text_2' => 'This is text 2!',
);
}
function test_get_transal() {
<?php
function test_get_def_transal() {
// возвращаем массив, со значениями по умолчанию
return array(
'text_1' => 'This is text 1!',
'text_2' => 'This is text 2!',
);
}
function test_get_transal() {
// применяем фильтры и возвращаем значения Опции или значения по умолчанию
@max-kk
max-kk / main_file_for_get_user_city_by_IP.php
Last active October 5, 2016 21:09
How to get user city with PHP + AJAX
<!-- ФАЙЛ должен быть .php -->
<!-- // Для начала подключим бибилиотку jQuery и jQuery cookie для сохранения города в Cookie -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://yandex.st/jquery/cookie/1.0/jquery.cookie.min.js"></script>
<?php
// Тперь получим ip посетителя и создадим переменую,
// что-бы скрипт мог ее использовать
if (isset($_SERVER['HTTP_X_REAL_IP'])) {
$ip = $_SERVER['HTTP_X_REAL_IP'];
@max-kk
max-kk / 0_reuse_code.js
Created November 20, 2015 12:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@max-kk
max-kk / limit-home.php
Created March 11, 2016 18:26
Limit photos count on specified page:
<?php
//$photosModel = apply_filters( 'fv/public/pre_get_comp_items_list/model', $photosModel, $konurs_enabled, $AJAX_ACTION, $contest_id );
add_filter( 'fv/public/pre_get_comp_items_list/model', 'fv_filter_home_photos_count', 10, 4 );
function fv_filter_home_photos_count($photosModel, $konurs_enabled, $AJAX_ACTION, $contest_id) {
if (!$AJAX_ACTION && is_front_page()) {
// for change limit on other page replace "is_front_page()" to "is_page(22)" where "22" - page ID
$photosModel->limit( 5 );
@max-kk
max-kk / filter_user_avatar.php
Created March 13, 2016 11:34
Wordpress: How to filter & replace user avatar based on meta filed (where saved avatar attachment_id).
<?php
function custom_modify_get_avatar($args, $id_or_email) {
$avatar_att_id = get_user_meta( get_current_user_id(), '_avatar_att_id', true );
if($avatar_att_id) {
$avatar_att_url = wp_get_attachment_image_src($avatar_att_id, array($args['width'], $args['height']));
if ( !empty($avatar_att_url) ) {
$args['url'] = $avatar_att_url[0];
}
}
return $args;
@max-kk
max-kk / fv-og-meta.php
Created April 25, 2016 12:17
Add OG meta
<?php
function fv_wp_head_og() {
echo '<!-- fv_wp_head_og -->';
global $photo_obj;
// FIX for big images
$thumb_size = array(
'width' => 1400,
'height' => 1000,
jQuery.cachedScript = function( url, options ) {
// Allow user to set any option except for dataType, cache, and url
options = $.extend( options || {}, {
dataType: "script",
cache: true,
url: url
});
// Use $.ajax() since it is more flexible than $.getScript
@max-kk
max-kk / fv_filter_list_variables.php
Last active May 5, 2016 13:53
Change description to full_description in photos list
<?php
// Hook includes/class-fv-functions.php :: render_template()
//apply_filters( 'fv_template_variables', $variables, $type, $template_path );
add_filter( 'fv_template_variables', 'fv_change_descr_to_full_descr', 10, 2 );
function fv_change_descr_to_full_descr($variables, $type) {
if ($type == 'theme') {
$variables['description'] = $variables['photo']->full_description;
}