Skip to content

Commit d2debbc

Browse files
committed
Two tracker plugins, next step for Blokks
1 parent 44e9236 commit d2debbc

8 files changed

Lines changed: 423 additions & 21 deletions

File tree

content-blokk/class-blokk.php

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
/**
3+
* _file comment
4+
*
5+
* @package blokk
6+
*/
7+
8+
9+
/**
10+
* Register a custom post type called blokk.
11+
*/
12+
class Blokk {
13+
14+
public function __construct() {
15+
16+
add_action( 'init', array( $this, 'register_cpt' ) );
17+
add_action( 'init', array( $this, 'register_shortcodes' ) );
18+
// Polylang support
19+
add_filter( 'pll_get_post_types', array( $this, 'pll_get_post_types' ), 0 );
20+
}
21+
22+
public function pll_get_post_types( $types ) {
23+
24+
return array_merge( $types, array( 'blokk' => 'blokk' ) );
25+
}
26+
27+
public function register_cpt() {
28+
29+
$args = array (
30+
'label' => 'Blokk',
31+
'labels' => array (
32+
'name' => 'Blokks',
33+
'singular_name' => 'Blokk',
34+
'menu_name' => 'Blokks',
35+
'add_new' => 'Add New',
36+
'add_new_item' => 'Add New Blokk',
37+
'new_item' => 'New Blokk',
38+
'edit' => 'Edit',
39+
'edit_item' => 'Edit Blokk',
40+
'view' => 'View Blokk',
41+
'view_item' => 'View Blokk',
42+
'all_items' => 'All Blokks',
43+
'search_items' => 'Search Blokks',
44+
'not_found' => 'No Blokks Found',
45+
'not_found_in_trash' => 'No Blokks Found in Trash',
46+
'parent' => 'Parent Blokk',
47+
'parent_item_colon' => 'Parent Blokk:',
48+
'feature_image' => 'Featured Image',
49+
'set_featured_image' => 'Set featured image',
50+
'remove_featured_image' => 'Remove featured image',
51+
'use_featured_image' => 'Use as featured image',
52+
'archives' => 'Blokk Archives',
53+
'insert_into_item' => 'Insert into Blokk',
54+
'uploaded_to_this_item' => 'Uploaded to this Blokk',
55+
'filter_items_list' => 'Filter Blokks lists',
56+
'items_list_navigation' => 'Blokks navigation',
57+
'items_list' => 'Blokks list',
58+
),
59+
'description' => 'Content blokk',
60+
'public' => false,
61+
'publicly_queryable' => false,
62+
'exclude_from_search' => false,
63+
'show_ui' => true,
64+
'show_in_menu' => true,
65+
'show_in_nav_menus' => true,
66+
'show_in_admin_bar' => true,
67+
'menu_icon' => 'dashicons-layout',
68+
'menu_position' => 18,
69+
'capability_type' => 'post',
70+
'map_meta_cap' => true,
71+
'hierarchical' => false,
72+
'supports' => array (
73+
0 => 'title',
74+
1 => 'editor',
75+
2 => 'revisions',
76+
),
77+
'has_archive' => false,
78+
'rewrite' => false,
79+
'query_var' => false,
80+
'can_export' => true,
81+
);
82+
register_post_type( 'blokk', $args );
83+
}
84+
85+
public function register_shortcodes() {
86+
87+
add_shortcode( 'blokk', array( $this, 'blokk_shortcode' ) );
88+
}
89+
90+
/**
91+
* Return a blokks content by its ID or slug
92+
*
93+
* @param
94+
* @param
95+
* @param
96+
*
97+
* @return string Blokk contents.
98+
*/
99+
public function blokk_shortcode( $attr, $content, $shortcode_tag ) {
100+
101+
$attr = shortcode_atts( array(
102+
'id' => 0,
103+
'name' => '',
104+
), $attr, $shortcode_tag );
105+
$post_content = '';
106+
107+
// Get blokk by name or slug
108+
if ( 0 !== $attr['id'] ) {
109+
$post = get_post( $attr['id'] );
110+
} elseif ( '' !== $attr['name'] ) {
111+
$post = get_page_by_path( $attr['name'], OBJECT, 'blokk' );
112+
}
113+
114+
// Display content or a warning
115+
if ( $post instanceof WP_Post ) {
116+
$post_content = apply_filters( 'the_content', $post->post_content );
117+
} elseif( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
118+
$post_content = '<span style="color: red;">WARNING: Invalid blokk ID/slug!</span>';
119+
}
120+
121+
return $post_content;
122+
}
123+
}

content-blokk/theme-shortcakes.php

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
<?php
2+
3+
add_action( 'init', 'dupplex_register_shortcodes' );
4+
add_action( 'register_shortcode_ui', 'dupplex_gomb_shortcode_ui' );
5+
add_action( 'register_shortcode_ui', 'dupplex_doboz_shortcode_ui' );
6+
7+
function dupplex_register_shortcodes() {
8+
9+
add_shortcode( 'gomb', 'dupplex_gomb' );
10+
add_shortcode( 'doboz', 'dupplex_doboz' );
11+
}
12+
13+
function dupplex_gomb( $attr, $content, $shortcode_tag ) {
14+
15+
$attr = shortcode_atts( array(
16+
'post_id' => 0,
17+
'buttontype' => 0,
18+
'target' => 'false',
19+
), $attr, $shortcode_tag );
20+
21+
// No output without content
22+
if ( empty( $attr['post_id'] ) ) {
23+
return '';
24+
}
25+
26+
// Set button type
27+
switch ( $attr['buttontype'] ) {
28+
case '1':
29+
$classes = 'arrow arrow-left';
30+
break;
31+
case '2':
32+
$classes = 'arrow arrow-right';
33+
break;
34+
case '0':
35+
default:
36+
$classes = 'btn btn-more';
37+
break;
38+
}
39+
40+
// Set link
41+
$post = get_post( $attr['post_id'] );
42+
if ( $post instanceof WP_Post ) {
43+
$permalink = get_permalink( $post );
44+
} else {
45+
$permalink = '#';
46+
}
47+
48+
$tag = sprintf( '<a href="%s" class="%s"%s>%s</a>',
49+
esc_attr( $permalink ),
50+
esc_attr( $classes ),
51+
( 'true' === $attr['target'] ) ? ' target="_blank"' : '',
52+
esc_html( $content )
53+
);
54+
55+
return $tag;
56+
}
57+
58+
function dupplex_gomb_shortcode_ui() {
59+
60+
$fields = array(
61+
array(
62+
'label' => esc_html__( 'Gomb hivatkozása', 'dupplex' ),
63+
'description' => esc_html__( 'A cél Oldal megadása.', 'dupplex' ),
64+
'attr' => 'post_id',
65+
'type' => 'post_select',
66+
'query' => array( 'post_type' => 'page' ),
67+
'meta' => array(
68+
'required' => true,
69+
),
70+
),
71+
array(
72+
'label' => esc_html__( 'Gomb típus', 'dupplex' ),
73+
'description' => esc_html__( 'Válassza ki a gomb típusát.', 'dupplex' ),
74+
'attr' => 'buttontype',
75+
'type' => 'radio',
76+
'options' => array(
77+
'0' => 'Akció gomb',
78+
'1' => 'Balra nyíl',
79+
'2' => 'Jobbra nyíl',
80+
),
81+
),
82+
array(
83+
'label' => esc_html__( 'Megnyitása új ablakban', 'dupplex' ),
84+
'description' => esc_html__( 'A gombra kattintáskor új ablak nyílik.', 'dupplex' ),
85+
'attr' => 'target',
86+
'type' => 'checkbox',
87+
),
88+
);
89+
90+
$shortcode_ui_args = array(
91+
'label' => esc_html__( 'Gomb', 'dupplex' ),
92+
'listItemImage' => 'dashicons-admin-links',
93+
'inner_content' => array(
94+
'label' => esc_html__( 'Gomb felirat', 'dupplex' ),
95+
'description' => esc_html__( 'Ez lesz a gombon olvasható.', 'dupplex' ),
96+
'value' => __( 'Bővebben', 'dupplex' ),
97+
),
98+
'post_type' => array( 'page', 'blokk' ),
99+
'attrs' => $fields,
100+
);
101+
102+
shortcode_ui_register_for_shortcode( 'gomb', $shortcode_ui_args );
103+
}
104+
105+
function dupplex_doboz( $attr, $content, $shortcode_tag ) {
106+
107+
$attr = shortcode_atts( array(
108+
'post_id' => 0,
109+
'title' => '',
110+
'h1' => 'false',
111+
'columns' => 'col-md-4',
112+
'bgcolor' => '',
113+
), $attr, $shortcode_tag );
114+
$post_content = '';
115+
116+
// No output without content
117+
if ( empty( $attr['post_id'] ) ) {
118+
return '';
119+
}
120+
121+
// Set header type (H1/H2)
122+
if ( 'true' === $attr['h1'] ) {
123+
$header = 'h1';
124+
} else {
125+
$header = 'h2';
126+
}
127+
128+
// Set title
129+
if ( empty( $attr['title'] ) ) {
130+
$title_html = '';
131+
} else {
132+
$title_html = sprintf( '<%s>%s</%1$s>', $header, esc_html( $attr['title'] ) );
133+
}
134+
135+
// Set content
136+
$post = get_post( $attr['post_id'] );
137+
if ( $post instanceof WP_Post ) {
138+
// FIXME Raw content for images = "doboz" without title
139+
$post_content = ( '' === $title_html ) ? $post->post_content : apply_filters( 'the_content', $post->post_content );
140+
} elseif( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
141+
$post_content = '<span style="color: red;">WARNING: Invalid blokk ID/slug!</span>';
142+
}
143+
144+
// Background color wrapper
145+
if ( empty( $attr['bgcolor'] ) ) {
146+
$bgcolor_html_open = '';
147+
$bgcolor_html_close = '';
148+
} else {
149+
$bgcolor_html_open = sprintf( '<div class="%s">', esc_attr( $attr['bgcolor'] ) );
150+
$bgcolor_html_close = '</div>';
151+
}
152+
153+
$html = sprintf( '<div class="%s">%s%s%s%s</div>',
154+
esc_attr( $attr['columns'] ),
155+
$bgcolor_html_open,
156+
$title_html,
157+
$post_content,
158+
$bgcolor_html_close
159+
);
160+
161+
return $html;
162+
}
163+
164+
function dupplex_doboz_shortcode_ui() {
165+
166+
$fields = array(
167+
array(
168+
'label' => esc_html__( 'Doboz cím', 'dupplex' ),
169+
'description' => esc_html__( 'A NAGYBETŰS címet csak nagy Kezdőbetűvel írja be.', 'dupplex' ),
170+
'attr' => 'title',
171+
'type' => 'text',
172+
'meta' => array(
173+
'placeholder' => 'Nagybetűs doboz cím',
174+
'required' => true,
175+
),
176+
),
177+
array(
178+
'label' => esc_html__( 'Főcím', 'dupplex' ),
179+
'description' => esc_html__( 'Az első doboznál állítson be főcímet.', 'dupplex' ),
180+
'attr' => 'h1',
181+
'type' => 'checkbox',
182+
),
183+
array(
184+
'label' => esc_html__( 'Tartalmi blokk', 'dupplex' ),
185+
'description' => esc_html__( 'Válassza ki melyik tartalom jelenjen meg a dobozban.', 'dupplex' ),
186+
'attr' => 'post_id',
187+
'type' => 'post_select',
188+
'query' => array( 'post_type' => 'blokk' ),
189+
),
190+
array(
191+
'label' => esc_html__( 'Doboz szélesség', 'dupplex' ),
192+
'description' => esc_html__( 'A főoldalon például 8 és 4 széles dobozok vannak.', 'dupplex' ),
193+
'attr' => 'columns',
194+
'type' => 'radio',
195+
'options' => array(
196+
'col-md-3' => '3 tizenketted széles',
197+
'col-md-4' => '4 tizenketted széles',
198+
'col-md-6' => '6 tizenketted széles',
199+
'col-md-8' => '8 tizenketted széles',
200+
'col-md-12' => '12 tizenketted széles',
201+
),
202+
),
203+
array(
204+
'label' => esc_html__( 'Háttérszín', 'dupplex' ),
205+
'description' => esc_html__( 'Válassza ki a doboz hátterszínét.', 'dupplex' ),
206+
'attr' => 'bgcolor',
207+
'type' => 'radio',
208+
'options' => array(
209+
'' => esc_html__( 'Átlátszó (képhez)', 'dupplex' ),
210+
'blue-bg' => esc_html__( 'Sötétkék', 'dupplex' ),
211+
'green-bg' => esc_html__( 'Türkiz', 'dupplex' ),
212+
'white-bg' => esc_html__( 'Fehér', 'dupplex' ),
213+
),
214+
),
215+
);
216+
217+
$shortcode_ui_args = array(
218+
'label' => esc_html__( 'Doboz', 'dupplex' ),
219+
'listItemImage' => 'dashicons-editor-table',
220+
'post_type' => array( 'page' ),
221+
'attrs' => $fields,
222+
);
223+
224+
shortcode_ui_register_for_shortcode( 'doboz', $shortcode_ui_args );
225+
}

google-universal-analytics/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @TODO - Google Universal Analytics for WordPress
22

3+
add_inline to jquery-core
4+
5+
// Track basic JavaScript errors - http://davidwalsh.name/track-errors-google-analytics
6+
window.addEventListener('error', function (e) {
7+
ga('send', 'exception', {'exDescription':e.message, 'exFatal':true, 'line':e.filename + ': ' + e.lineno});
8+
});
9+
// Track AJAX errors
10+
jQuery(document).ajaxError(function (e, request, settings) {
11+
ga('send', 'exception', {'exDescription':'AJAX error', 'exFatal':true, 'url':settings.url, 'result':e.result});
12+
});
13+
314
How it works... in "General Settings"
415

516
+ obfuscate UA number

0 commit comments

Comments
 (0)