Last active
November 10, 2015 13:43
-
-
Save brunoalex/723e712f6c26a8feef1e to your computer and use it in GitHub Desktop.
save to lib from GF
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 | |
/*-----------------------------------------------------------------------------------*/ | |
/* This file will be referenced every time a template/page loads on your Wordpress site | |
/* This is the place to define custom fxns and specialty code | |
/*-----------------------------------------------------------------------------------*/ | |
// Define the version so we can easily replace it throughout the theme | |
define( 'NAKED_VERSION', 1.0 ); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Add Rss feed support to Head section | |
/*-----------------------------------------------------------------------------------*/ | |
add_theme_support( 'automatic-feed-links' ); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Register main menu for Wordpress use | |
/*-----------------------------------------------------------------------------------*/ | |
register_nav_menus( | |
array( | |
'primary' => __( 'Primary Menu', 'naked' ), // Register the Primary menu | |
// Copy and paste the line above right here if you want to make another menu, | |
// just change the 'primary' to another name | |
) | |
); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Activate sidebar for Wordpress use | |
/*-----------------------------------------------------------------------------------*/ | |
function naked_register_sidebars() { | |
register_sidebar(array( // Start a series of sidebars to register | |
'id' => 'sidebar', // Make an ID | |
'name' => 'Sidebar', // Name it | |
'description' => 'Take it on the side...', // Dumb description for the admin side | |
'before_widget' => '<div>', // What to display before each widget | |
'after_widget' => '</div>', // What to display following each widget | |
'before_title' => '<h3 class="side-title">', // What to display before each widget's title | |
'after_title' => '</h3>', // What to display following each widget's title | |
'empty_title'=> '', // What to display in the case of no title defined for a widget | |
// Copy and paste the lines above right here if you want to make another sidebar, | |
// just change the values of id and name to another word/name | |
)); | |
} | |
// adding sidebars to Wordpress (these are created in functions.php) | |
add_action( 'widgets_init', 'naked_register_sidebars' ); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Enqueue Styles and Scripts | |
/*-----------------------------------------------------------------------------------*/ | |
function naked_scripts() { | |
// get the theme directory style.css and link to it in the header | |
wp_enqueue_style( 'naked-style', get_template_directory_uri() . '/style.css', '10000', 'all' ); | |
// add fitvid | |
wp_enqueue_script( 'naked-fitvid', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), NAKED_VERSION, true ); | |
// add theme scripts | |
wp_enqueue_script( 'naked', get_template_directory_uri() . '/js/theme.min.js', array(), NAKED_VERSION, true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'naked_scripts' ); // Register this fxn and allow Wordpress to call it automatcally in the header | |
show_admin_bar( true ); | |
function register_my_menus() { | |
register_nav_menus( | |
array( | |
'header-menu' => __( 'Header Menu' ), | |
'footer-menu' => __( 'Footer-menu' ) | |
) | |
); | |
} | |
add_action( 'init', 'register_my_menus' ); | |
// add_theme_support( ‘post-thumbnails’ ); | |
if ( function_exists( 'add_theme_support' ) ) { | |
add_theme_support( 'post-thumbnails' ); | |
// add_image_size($name, $width, $height, $cropBoolean); | |
add_image_size('featuredImageCropped', 600, 403, true); | |
add_image_size('featuredImageCropped3', 188, 128, true); | |
add_image_size('featuredImageCropped4', 220, 120, false); | |
add_image_size('featuredImageCropped1', 403, 403, true); | |
add_image_size('featuredImageCropped2', 280, 180, true); | |
add_image_size('fullmark', 900 ,0, false); | |
add_image_size('fullmark1', 800 ,0, false); | |
add_image_size('books', 600 ,700, false); | |
add_image_size('logo_cliente1', 400,0, false); | |
add_image_size( 'home', 120, 420, array( 'left', 'top' ) ); | |
add_image_size( 'cliente', 600, array( 'left', 'top' ) ); | |
} | |
function custom_excerpt_length( $length ) { | |
return 25; | |
} | |
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); | |
add_action('get_header', 'my_filter_head'); | |
function my_filter_head() { | |
remove_action('wp_head', '_admin_bar_bump_cb'); | |
} | |
// custom admin login logo | |
function custom_login_logo() { | |
echo '<style type="text/css"> | |
h1 a { background-image: url('.get_bloginfo('template_directory').'/images/adminlogo.png) !important; } | |
</style>'; | |
} | |
add_action('login_head', 'custom_login_logo'); | |
// example custom dashboard widget | |
function custom_dashboard_widget() { | |
echo '<div style="text-align:center;">'; | |
echo "<p>Design and Cooding by Bruno Alexandre.<br /> Comments and bug reports can be send to brunoalex9@msn.com</p>"; | |
echo '<img src="http://www.toppromomkt.com/wp-content/themes/toppromo/images/logo.png" border=0>'; echo '</div>'; | |
} | |
function add_custom_dashboard_widget() { | |
wp_add_dashboard_widget('custom_dashboard_widget', 'TopPromo Design by Bruno Alexandre', 'custom_dashboard_widget'); | |
} | |
add_action('wp_dashboard_setup', 'add_custom_dashboard_widget'); | |
// example custom dashboard widget | |
function custom_dashboard_widget1() { | |
echo '<div style="text-align:center;">'; | |
echo "<p>SIR - Sistema Integrado de Relatórios activado </br> Design e programação : brunoalex@kilt-design.com</p>"; | |
echo '<a href="http://www.toppromomkt.com/lista_sir/"><img src="http://www.toppromomkt.com/wp-content/themes/toppromo/images/sir_logo_adm.png" border=0></a>'; echo '</div>'; | |
} | |
function add_custom_dashboard_widget1() { | |
wp_add_dashboard_widget('custom_dashboard_widget1', 'SIR - Sistema Itegrado de Relatórios', 'custom_dashboard_widget1'); | |
} | |
add_action('wp_dashboard_setup', 'add_custom_dashboard_widget1'); | |
// example custom dashboard widget | |
function custom_dashboard_widget2() { | |
echo '<div style="text-align:center;">'; | |
echo "<p>Jupiter - Sistema Gestão de Recursos Humanos </br> Design e programação : brunoalex@kilt-design.com</p>"; | |
echo '<a href="http://www.toppromomkt.com/jupiter/"><img src="http://www.toppromomkt.com/wp-content/themes/toppromo/images/jupiter_7.png" border=0></a>'; echo '</div>'; | |
} | |
function add_custom_dashboard_widget2() { | |
wp_add_dashboard_widget('custom_dashboard_widget2', 'Jupiter - Sistema Gestão de Recursos Humanos', 'custom_dashboard_widget2'); | |
} | |
add_action('wp_dashboard_setup', 'add_custom_dashboard_widget2'); | |
function custom_dashboard_widget3() { | |
echo '<div style="text-align:center;">'; | |
echo "<p>TopBooks - Sistema de Produção de Porfolio de Promotoras para Clientes </br> Design e programação : brunoalex@kilt-design.com</p>"; | |
echo '<a href="http://www.toppromomkt.com/wp-admin/edit.php?post_type=books"><img src="http://www.toppromomkt.com/wp-content/themes/toppromo/images/tb.png" border=0></a>'; echo '</div>'; | |
} | |
function add_custom_dashboard_widget3() { | |
wp_add_dashboard_widget('custom_dashboard_widget3', 'TopBooks - Sistema de Produção de Porfolio de Promotoras para Clientes', 'custom_dashboard_widget3'); | |
} | |
add_action('wp_dashboard_setup', 'add_custom_dashboard_widget3'); | |
// Admin footer modification | |
function remove_footer_admin () | |
{ | |
echo '<span id="footer-thankyou">Developed by <a href="http://www.kilt-design.com" target="_blank">Bruno Alexandre </a></span>'; | |
} | |
add_filter('admin_footer_text', 'remove_footer_admin'); | |
add_action( 'admin_bar_menu', 'remove_wp_logo', 999 ); | |
function remove_wp_logo( $wp_admin_bar ) { | |
$wp_admin_bar->remove_node( 'wp-logo' ); | |
} | |
function loginpage_custom_link() { | |
return 'http://toppromomkt.com'; | |
} | |
add_filter('login_headerurl','loginpage_custom_link'); | |
function change_title_on_logo() { | |
return 'TopPromo Ponto de Venda'; | |
} | |
add_filter('login_headertitle', 'change_title_on_logo'); | |
function revcon_change_post_label() { | |
global $menu; | |
global $submenu; | |
$menu[5][0] = 'Notícias'; | |
$submenu['edit.php'][5][0] = 'Notícias'; | |
$submenu['edit.php'][10][0] = 'Add Notícias'; | |
$submenu['edit.php'][16][0] = 'Notícias Tags'; | |
echo ''; | |
} | |
function revcon_change_post_object() { | |
global $wp_post_types; | |
$labels = &$wp_post_types['post']->labels; | |
$labels->name = 'Notícias'; | |
$labels->singular_name = 'Notícia'; | |
$labels->add_new = 'Add Notícias'; | |
$labels->add_new_item = 'Add Notícias'; | |
$labels->edit_item = 'Edit Notícias'; | |
$labels->new_item = 'Notícias'; | |
$labels->view_item = 'Ver Notícias'; | |
$labels->search_items = 'Procurar Notícias'; | |
$labels->not_found = 'No News found'; | |
$labels->not_found_in_trash = 'No News found in Trash'; | |
$labels->all_items = 'Todas as Notícias'; | |
$labels->menu_name = 'Notícias'; | |
$labels->name_admin_bar = 'Notícias'; | |
} | |
add_action( 'admin_menu', 'revcon_change_post_label' ); | |
add_action( 'init', 'revcon_change_post_object' ); | |
add_filter( 'image_size_names_choose', 'my_custom_sizes' ); | |
function my_custom_sizes( $sizes ) { | |
return array_merge( $sizes, array( | |
'your-custom-size' => __( 'Your Custom Size Name' ), | |
) ); | |
} | |
if ( function_exists( 'add_image_size' ) ) { | |
add_image_size( 'new-size', 350, 250, false ); //(cropped) | |
} | |
add_filter('image_size_names_choose', 'my_image_sizes'); | |
function my_image_sizes($sizes) { | |
$addsizes = array( | |
"new-size" => __( "Sem_marca_dagua") | |
); | |
$newsizes = array_merge($sizes, $addsizes); | |
return $newsizes; | |
} | |
if ( function_exists('register_sidebar') ) { | |
register_sidebar(array( | |
'name' => 'Page Sidebar', | |
'id' => 'page-sidebar', | |
'description' => 'Sidebar das paginas simples', | |
'before_widget' => '<div style="height: 0px"></div><li id="%1$s" class="widget %2$s">', | |
'after_widget' => '</li>', | |
'before_title' => '<h2 class="widgettitle">', | |
'after_title' => '</h2>', | |
)); | |
} | |
function wpbeginner_numeric_posts_nav() { | |
if( is_singular() ) | |
return; | |
global $wp_query; | |
/** Stop execution if there's only 1 page */ | |
if( $wp_query->max_num_pages <= 1 ) | |
return; | |
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; | |
$max = intval( $wp_query->max_num_pages ); | |
/** Add current page to the array */ | |
if ( $paged >= 1 ) | |
$links[] = $paged; | |
/** Add the pages around the current page to the array */ | |
if ( $paged >= 3 ) { | |
$links[] = $paged - 1; | |
$links[] = $paged - 2; | |
} | |
if ( ( $paged + 2 ) <= $max ) { | |
$links[] = $paged + 2; | |
$links[] = $paged + 1; | |
} | |
echo '<div class="navigation"><ul>' . "\n"; | |
/** Previous Post Link */ | |
if ( get_previous_posts_link() ) | |
printf( '<li class="pre">%s</li>' . "\n", get_previous_posts_link() ); | |
/** Link to first page, plus ellipses if necessary */ | |
if ( ! in_array( 1, $links ) ) { | |
$class = 1 == $paged ? ' class="active"' : ''; | |
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); | |
if ( ! in_array( 2, $links ) ) | |
echo '<li>…</li>'; | |
} | |
/** Link to current page, plus 2 pages in either direction if necessary */ | |
sort( $links ); | |
foreach ( (array) $links as $link ) { | |
$class = $paged == $link ? ' class="active"' : ''; | |
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); | |
} | |
/** Link to last page, plus ellipses if necessary */ | |
if ( ! in_array( $max, $links ) ) { | |
if ( ! in_array( $max - 1, $links ) ) | |
echo '<li>…</li>' . "\n"; | |
$class = $paged == $max ? ' class="active"' : ''; | |
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); | |
} | |
/** Next Post Link */ | |
if ( get_next_posts_link() ) | |
printf( '<li>%s</li>' . "\n", get_next_posts_link() ); | |
echo '</ul></div>' . "\n"; | |
} | |
add_action( 'init', 'create_tag_taxonomies', 0 ); | |
add_filter( 'run_ngg_resource_manager', '__return_false' ); | |
// Filter to hide protected posts | |
function exclude_protected($where) { | |
global $wpdb; | |
return $where .= " AND {$wpdb->posts}.post_password = '' "; | |
} | |
// Decide where to display them | |
function exclude_protected_action($query) { | |
if( !is_single() && !is_page() && !is_admin() ) { | |
add_filter( 'posts_where', 'exclude_protected' ); | |
} | |
} | |
/* | |
add_action( 'wp', 'post_pw_sess_expire' ); | |
function post_pw_sess_expire() { | |
if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) | |
// Setting a time of 0 in setcookie() forces the cookie to expire with the session | |
setcookie('wp-postpass_' . COOKIEHASH, '', 1111, COOKIEPATH); | |
} | |
*/ | |
add_action('admin_head', 'my_custom_fonts'); | |
function my_custom_fonts() { | |
echo '<link rel="stylesheet" href="style.css" type="text/css" media="all" />'; | |
} | |
function separador_grafico( $atts ) | |
{ | |
echo '<div id="sep">Promoção de: '; | |
echo $atts["data"]; | |
echo '</div>'; | |
} | |
add_shortcode( 'sep', 'separador_grafico' ); | |
function separador_alerta( $atts ) | |
{ | |
echo '<div id="alerta_rel"><p>Alerta:</p> '; | |
echo $atts["txt"]; | |
echo '</div>'; | |
} | |
add_shortcode( 'alerta', 'separador_alerta' ); | |
add_action("gform_after_submission_2", "acf_post_submission", 10, 2); | |
function acf_post_submission ($entry, $form) | |
{ | |
$post_id = $entry["post_id"]; | |
$values = get_post_custom_values("carta_sip", $post_id); | |
update_field("simple_fields_fieldgroups_6_2_0", $values, $post_id); | |
} | |
add_filter( 'sf-before-form', 'myFunction' ); function myFunction(){ ?> | |
<script> | |
function showd() { | |
$('[data-id="7"]').show(); | |
$('[data-id="8"]').show(); | |
$('[data-id="9"]').show(); | |
$('[data-id="11"]').show(); | |
$('.btshow').hide(); | |
$('.btshow1').show(); | |
} | |
function showd1() { | |
$('[data-id="7"]').hide(); | |
$('[data-id="8"]').hide(); | |
$('[data-id="9"]').hide(); | |
$('[data-id="11"]').hide(); | |
$('.btshow').show(); | |
$('.btshow1').hide(); | |
} | |
function showd3() { | |
$('[data-id="1"]').hide(); | |
$('[data-id="2"]').hide(); | |
$('[data-id="3"]').hide(); | |
$('[data-id="4"]').hide(); | |
$('[data-id="5"]').hide(); | |
$('[data-id="6"]').hide(); | |
$('[data-id="7"]').hide(); | |
$('[data-id="8"]').hide(); | |
$('[data-id="9"]').hide(); | |
$('[data-id="11"]').hide(); | |
$('.sf-button-btnsearch').hide(); | |
$('.btshow3').hide(); | |
$('.btshow4').show(); | |
} | |
function showd4() { | |
$('[data-id="1"]').show(); | |
$('[data-id="2"]').show(); | |
$('[data-id="3"]').show(); | |
$('[data-id="4"]').show(); | |
$('[data-id="5"]').show(); | |
$('[data-id="6"]').show(); | |
$('[data-id="7"]').show(); | |
$('[data-id="8"]').show(); | |
$('[data-id="9"]').show(); | |
$('[data-id="11"]').show(); | |
$('.sf-button-btnsearch').show(); | |
$('.btshow3').show(); | |
$('.btshow4').hide(); | |
} | |
</script> | |
<a class="btshow" onclick="showd()"> | |
<p>Ver Opções Avançadas de pesquisa </a> </p> | |
<a class="btshow1" onclick="showd1()"> | |
<p>Ocultar Avançadas de pesquisa </a> </p> | |
<?php } | |
add_action("gform_after_submission", "add_custom_post_meta", 10, 2); | |
function add_custom_post_meta($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 16; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'disponibilidade_s', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta1", 10, 2); | |
function add_custom_post_meta1($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 15; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'talentos', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta2", 10, 2); | |
function add_custom_post_meta2($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 17; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'linguas', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta3", 10, 2); | |
function add_custom_post_meta3($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 27; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'recibos_verdes_link', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta4", 10, 2); | |
function add_custom_post_meta4($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 28; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'retençao_fiscal', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta5", 10, 2); | |
function add_custom_post_meta5($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 29; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'viatura_propria_link', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta7", 10, 2); | |
function add_custom_post_meta7($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 32; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'atividade_link', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta8", 10, 2); | |
function add_custom_post_meta8($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 38; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'dominio_de_tecnologias_link', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta10", 10, 2); | |
function add_custom_post_meta10($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 40; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], 'sabe_andar_de_patins_link', $checkbox_values); | |
} | |
add_action("gform_after_submission", "add_custom_post_meta11", 10, 2); | |
function add_custom_post_meta11($entry, $form) { | |
//NOTE: replace 4 below with your actually Gravity Forms checkbox field ID | |
$field_id = 18; | |
$checkbox_values = get_checkbox_value( $entry, $field_id ); | |
//NOTE: replace 'my_custom_meta' below with your WP Types custom field name | |
update_post_meta($entry['post_id'], '_simple_fields_fieldGroupID_5_fieldID_7_numInSet_0', $checkbox_values); | |
} | |
function get_checkbox_value( $entry, $field_id ){ | |
//getting a comma separated list of selected values | |
$lead_field_keys = array_keys( $entry ); | |
$items = array(); | |
foreach ( $lead_field_keys as $input_id ) { | |
if ( is_numeric( $input_id ) && absint( $input_id ) == $field_id ) { | |
$items[] = GFCommon::selection_display( rgar( $entry, $input_id ), null, $entry['currency'], false ); | |
} | |
} | |
$value = GFCommon::implode_non_blank( ', ', $items ); | |
return $value; | |
} | |
function tp_stop_guestes( $content ) { | |
global $post; | |
if ( $post->post_type == 'promotores' ) { | |
if ( !is_user_logged_in() ) { | |
header("Location: http://www.toppromomkt.com/wp-login.php"); | |
die(); | |
} | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'tp_stop_guestes' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment