-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
294 lines (272 loc) · 10.1 KB
/
functions.php
File metadata and controls
294 lines (272 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<?php
/**
* event_app functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package event_app
*/
include("inc/cleanwp.php");
if ( ! function_exists( 'event_app_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function event_app_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on event_app, use a find and replace
* to change 'event_app' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'event_app', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'menu-1' => esc_html__( 'Primary', 'event_app' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'gallery',
'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'event_app_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif;
add_action( 'after_setup_theme', 'event_app_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function event_app_content_width() {
$GLOBALS['content_width'] = apply_filters( 'event_app_content_width', 800 );
}
add_action( 'after_setup_theme', 'event_app_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function event_app_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'event_app' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'event_app' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'event_app_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function event_app_scripts() {
wp_enqueue_style( 'event_app-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'event_app_scripts' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function event_app_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
}
add_action( 'wp_head', 'event_app_pingback_header' );
//Remove unwanted JQuery
function my_init() {
if (!is_admin()) {
//wp_deregister_script('jquery');
//wp_register_script('jquery', get_template_directory_uri() . '/js/jquery-2.2.4.min.js', false, '2.2.4', true);
//wp_enqueue_script('jquery');
// load additional JS files
//wp_enqueue_script('site_js', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0', true);
}
}
add_action('init', 'my_init');
// Custom Scripting to Move JavaScript from the Head to the Footer
function remove_head_scripts() {
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
//add_action('wp_footer', 'wp_print_scripts', 5);
add_action('wp_footer', 'wp_enqueue_scripts', 5);
add_action('wp_footer', 'wp_print_head_scripts', 5);
}
add_action( 'wp_enqueue_scripts', 'remove_head_scripts' );
// END Custom Scripting to Move JavaScript
function prefix_add_footer_styles() {
wp_enqueue_style( 'styles', get_template_directory_uri() . '/wing.css?p='.time() );
};
add_action( 'get_footer', 'prefix_add_footer_styles' );
// Register Custom Post Type
function custom_local() {
$labels = array(
'name' => _x( 'Locais', 'Post Type General Name', 'event_app' ),
'singular_name' => _x( 'Local', 'Post Type Singular Name', 'event_app' ),
'menu_name' => __( 'Locais', 'event_app' ),
'name_admin_bar' => __( 'Locais', 'event_app' ),
'archives' => __( 'arquivo de locais', 'event_app' ),
'attributes' => __( 'Atributos', 'event_app' ),
'parent_item_colon' => __( 'Parent Item:', 'event_app' ),
'all_items' => __( 'Todos os locais', 'event_app' ),
'add_new_item' => __( 'Adicionar local', 'event_app' ),
'add_new' => __( 'Adicionar', 'event_app' ),
'new_item' => __( 'Novo local', 'event_app' ),
'edit_item' => __( 'Editar local', 'event_app' ),
'update_item' => __( 'Atualizar', 'event_app' ),
'view_item' => __( 'Ver', 'event_app' ),
'view_items' => __( 'Ver', 'event_app' ),
'search_items' => __( 'Procurar', 'event_app' ),
'not_found' => __( 'Não encontrado', 'event_app' ),
'not_found_in_trash' => __( 'Não encontrado na lixeira', 'event_app' ),
'featured_image' => __( 'Imagem destacada', 'event_app' ),
'set_featured_image' => __( 'Configure imagem', 'event_app' ),
'remove_featured_image' => __( 'Remover imagem', 'event_app' ),
'use_featured_image' => __( 'Usar imagem', 'event_app' ),
'insert_into_item' => __( 'Inserir', 'event_app' ),
'uploaded_to_this_item' => __( 'Publicar nesse local', 'event_app' ),
'items_list' => __( 'Lista de locais', 'event_app' ),
'items_list_navigation' => __( 'Items list navigation', 'event_app' ),
'filter_items_list' => __( 'Filter items list', 'event_app' ),
);
$args = array(
'label' => __( 'Local', 'event_app' ),
'description' => __( 'Local da atração', 'event_app' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-location',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
register_post_type( 'local', $args );
}
add_action( 'init', 'custom_local', 0 );
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
register_taxonomy(
'tipo_local',
'local', // this is the custom post type(s) I want to use this taxonomy for
array(
'hierarchical' => true,
'label' => 'Tipos',
'query_var' => true,
'rewrite' => true
)
);
register_taxonomy(
'tag_local',
'local', // this is the custom post type(s) I want to use this taxonomy for
array(
'hierarchical' => false,
'label' => 'Tags',
'query_var' => true,
'rewrite' => true
)
);
}
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Eventos';
$submenu['edit.php'][5][0] = 'Eventos';
$submenu['edit.php'][10][0] = 'Adicionar Eventos';
echo '';
}
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Eventos';
$labels->singular_name = 'Evento';
$labels->add_new = 'Adicionar Evento';
$labels->add_new_item = 'Adicionar Evento';
$labels->edit_item = 'Editar Eventos';
$labels->new_item = 'Evento';
$labels->view_item = 'Ver Evento';
$labels->search_items = 'Procurar Eventos';
$labels->not_found = 'Nenhum evento encontrado';
$labels->not_found_in_trash = 'Nada na lixeira';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );
function my_acf_init() {
acf_update_setting('google_api_key', 'AIzaSyAJvJGg1Z57TillQjND1FDiuqWlcYvt1Vs');
}
add_action('acf/init', 'my_acf_init');
// add the namespace to the RSS opening element
function add_media_namespace() {
echo "xmlns:media=\"http://search.yahoo.com/mrss/\"\n";
}
// add the requisite tag where a thumbnail exists
function add_media_thumbnail() {
global $post;
if( has_post_thumbnail( $post->ID )) {
$thumb_ID = get_post_thumbnail_id( $post->ID );
$details = wp_get_attachment_image_src($thumb_ID, 'large');
if( is_array($details) ) {
echo '<media:thumbnail url="' . $details[0]
. '" width="' . $details[1]
. '" height="' . $details[2] . '" />';
}
}
}
// add the two functions above into the relevant WP hooks
add_action( 'rss2_ns', 'add_media_namespace' );
add_action( 'rss2_item', 'add_media_thumbnail' );
function myfeed_request($qv) {
if (isset($qv['feed']) && !isset($qv['post_type']))
$qv['post_type'] = array('post', 'local');
return $qv;
}
add_filter('request', 'myfeed_request');
function feedFilter($query) {
if ($query->is_feed) {
//$query->set('order','ASC');
$query->set('orderby','rand');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');