-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
131 lines (106 loc) · 4.15 KB
/
functions.php
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
<?php
// Responsive Images fix //
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
// Post Thumbnail Support //
add_theme_support( 'post-thumbnails', array( 'lineas_de_trabajo', 'clientes'));
// Custom Post Types //
add_action( 'init', 'create_post_type' );
function create_post_type() {
// Lineas de Trabajo //
register_post_type( 'lineas_de_trabajo',
array(
'labels' => array(
'name' => 'Lineas de Trabajo',
'singular_name' => 'Linea de Trabajo'
),
'public' => true,
'supports' => array('thumbnail','title', 'editor')
)
);
// Clientes //
register_post_type( 'clientes',
array(
'labels' => array(
'name' => 'Clientes',
'singular_name' => 'Cliente'
),
'public' => true,
'supports' => array('thumbnail','title', 'editor')
)
);
}
//META BOXES PARA LINEAS DE TRABAJOS//
$new_meta_boxes =
array(
//COLUMNA//
"columna" => array
(
"name" => "columna",
"std" => "",
"title" => "Columnas"
),
);
function new_meta_boxes() {
global $post, $new_meta_boxes;
foreach($new_meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $meta_box['name'], true);
if($meta_box_value == "")
$meta_box_value = $meta_box['std'];
echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
echo'<h2>'.$meta_box['title'].'</h2>';
echo'<select name="'.$meta_box['name'].'"><option value="1">1 columna</option><option value="2">2 columnas</option></select><br />';
echo'<p><label for="'.$meta_box['name'].'">'.$meta_box['description'].'</label></p>';
}
}
function create_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', 'Post Settings', 'new_meta_boxes', 'lineas_de_trabajo', 'normal', 'core' );
}
}
function save_postdata( $post_id ) {
global $post, $new_meta_boxes;
foreach($new_meta_boxes as $meta_box) {
// Verify
if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
}
else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}
$data = $_POST[$meta_box['name']];
if(get_post_meta($post_id, $meta_box['name']) == "")
add_post_meta($post_id, $meta_box['name'], $data, true);
elseif($data != get_post_meta($post_id, $meta_box['name'], true))
update_post_meta($post_id, $meta_box['name'], $data);
elseif($data == "")
delete_post_meta($post_id, $meta_box['name'], get_post_meta($post_id, $meta_box['name'], true));
}
}
add_action('admin_menu', 'create_meta_box');
add_action('save_post', 'save_postdata');
// Scrip Carrusel //
wp_register_script('mousewheel', get_bloginfo('template_url') . '/js/jquery.mousewheel.js', array('jquery'), 1.1, true);
wp_register_script('intent', get_bloginfo('template_url') . '/js/mwheelIntent.js', array('jquery'), 1.1, true);
wp_register_script('scrollpane', get_bloginfo('template_url') . '/js/jquery.jscrollpane.min.js', array('jquery', 'mousewheel', 'intent'), 1.1, true);
wp_register_script('carousel', get_bloginfo('template_url') . '/js/jquery.jcarousel.min.js', array('jquery'), 1.1, true);
wp_register_script('fittext', get_bloginfo('template_url') . '/js/jquery.fittext.js', array('jquery'), 1.1, true);
wp_register_script('google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp', true );
wp_enqueue_script('main', get_bloginfo('template_url') . '/js/min/main-min.js', array('carousel', 'fittext', 'google-maps'), 1.1, true);
wp_enqueue_script('scroll', get_bloginfo('template_url') . '/js/min/scroll-min.js', array('jquery', 'scrollpane'));
wp_enqueue_style('scroll_style', get_bloginfo('template_url') . '/css/jquery.jscrollpane.css');
// Leer más //
function new_excerpt_more( $more ) {
return '<a href="#" class="readmore"><span>+</span> Leer más</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');