PluginProbe
Assistant – Every Day Productivity Apps / 1.5.5.1
Assistant – Every Day Productivity Apps v1.5.5.1
1.5.5.1 1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 All 72 releases
← All changes | backend/src/Providers/HooksServiceProvider.php +29 -56 0.3.1 → 1.5.5.1 View file →
@@ -1,9 +1,10 @@
1 1 <?php
2 2
3 -
4 3 namespace FL\Assistant\Providers;
5 4
5 +use FL\Assistant\System\Contracts\ServiceProviderAbstract;
6 +use FL\Assistant\Helpers\BeaverBuilderHelper;
6 7
7 8 use FL\Assistant\Hooks\Actions\OnEditUserProfile;
8 9 use FL\Assistant\Hooks\Actions\OnEnqueueScripts;
9 10 use FL\Assistant\Hooks\Actions\OnPersonalOptionsUpdate;
@@ -9,16 +10,21 @@
9 10 use FL\Assistant\Hooks\Actions\OnPersonalOptionsUpdate;
10 11 use FL\Assistant\Hooks\Actions\OnWPBeforeAdminBarRender;
11 12 use FL\Assistant\Hooks\Actions\OnBeforeDeletePost;
12 13 use FL\Assistant\Hooks\Actions\OnDeleteTerm;
14 +use FL\Assistant\Hooks\Actions\OnCustomizeRegister;
15 +use FL\Assistant\Hooks\Actions\OnWPHead;
16 +use FL\Assistant\Hooks\Actions\OnWP;
17 +
13 18 use FL\Assistant\Hooks\Filters\OnHeartbeatReceived;
14 19 use FL\Assistant\Hooks\Filters\OnFLBuilderUIBarButtons;
15 -use FL\Assistant\System\Contracts\ServiceProviderAbstract;
16 -use FL\Assistant\Data\Transformers\NotationsTransformer;
17 -use FL\Assistant\Data\Repository\NotationsRepository;
18 -use FL\Assistant\Data\Repository\LabelsRepository;
19 -use FL\Assistant\Data\Transformers\LabelsTransformer;
20 +use FL\Assistant\Hooks\Filters\OnScriptLoaderTag;
20 21
22 +use FL\Assistant\Hooks\AdminColumns;
23 +use FL\Assistant\Hooks\ImageProxy;
24 +use FL\Assistant\Hooks\PostPreview;
25 +use FL\Assistant\Hooks\CustomizerPreview;
26 +
21 27 class HooksServiceProvider extends ServiceProviderAbstract {
22 28
23 29 /**
24 30 * @throws \FL\Assistant\System\Container\InjectionException
@@ -32,8 +38,13 @@
32 38 );
33 39
34 40 $this->actions();
35 41 $this->filters();
42 +
43 + new AdminColumns();
44 + new ImageProxy();
45 + new PostPreview();
46 + new CustomizerPreview();
36 47 }
37 48
38 49 public function actions() {
39 50
@@ -38,10 +49,12 @@
38 49 public function actions() {
39 50
40 51 // Enqueue Assistant frontend
41 52 $enqueue_scripts = $this->injector->make( OnEnqueueScripts::class );
42 - add_action( 'wp_enqueue_scripts', $enqueue_scripts );
43 - add_action( 'admin_enqueue_scripts', $enqueue_scripts );
53 + $priority = BeaverBuilderHelper::is_assistant_extension() ? 1 : 10;
54 + add_action( 'wp_enqueue_scripts', $enqueue_scripts, $priority );
55 + add_action( 'admin_enqueue_scripts', $enqueue_scripts, $priority );
56 + add_action( 'fl_builder_ui_enqueue_scripts', $enqueue_scripts, $priority );
44 57
45 58 // setup user profile meta fields - shows on YOUR profile, not on others.
46 59 add_action( 'show_user_profile', $this->injector->make( OnEditUserProfile::class ) );
47 60 add_action( 'personal_options_update', $this->injector->make( OnPersonalOptionsUpdate::class ) );
@@ -54,8 +67,15 @@
54 67
55 68 // taxonomy actions
56 69 add_action( 'delete_term', $this->injector->make( OnDeleteTerm::class ) );
57 70
71 + // Customize register
72 + add_action( 'customize_register', $this->injector->make( OnCustomizeRegister::class ) );
73 +
74 + // Code snippets
75 + add_action( 'wp_head', $this->injector->make( OnWPHead::class ) );
76 + add_action( 'wp', $this->injector->make( OnWP::class ) );
77 +
58 78 }
59 79
60 80 public function filters() {
61 81
@@ -63,54 +83,7 @@
63 83 add_filter( 'heartbeat_received', $this->injector->make( OnHeartbeatReceived::class ), 11, 2 );
64 84
65 85 add_filter( 'fl_builder_ui_bar_buttons', $this->injector->make( OnFLBuilderUIBarButtons::class ) );
66 86
67 - // Setup custom WP admin post list columns
68 - $this->enqueue_custom_admin_columns();
69 - }
70 -
71 - public function enqueue_custom_admin_columns() {
72 -
73 - $types = get_post_types( [ 'public' => true ], 'objects' );
74 -
75 - foreach ( $types as $type => $info ) {
76 - add_filter( "manage_{$type}_posts_columns", [ $this, 'add_columns' ] );
77 - add_action( "manage_{$type}_posts_custom_column", [ $this, 'render_column' ], 10, 2 );
78 - }
79 - }
80 -
81 - public function add_columns( $columns ) {
82 - $columns['fl_assistant'] = __( 'Assistant', 'fl-assistant' );
83 - return $columns;
84 - }
85 -
86 - public function render_column( $column, $post_id ) {
87 - $vars = '--fl-asst-red: #FF5335; --fl-asst-blue: #1BADF8; --fl-asst-green: #00D281; --fl-asst-yellow: #FFD000; --fl-asst-orange: #FF9500; --fl-asst-purple: #CC73E1; --fl-asst-pink: #FF2968;';
88 - $styles = "{$vars} padding: 2px 5px; display: inline-flex; flex: 0 0 auto; border-radius: 20px; border: 1px solid #d2d2d2; align-items: center; color: black; background: white; margin: 2px 5px 3px; margin-left:0;";
89 - $dot = 'width: 10px; height: 10px; flex: 0 0 10px; border-radius: 7px; background: blue; margin-right: 5px;';
90 -
91 - if ( 'fl_assistant' === $column ) {
92 - $transformer = new NotationsTransformer;
93 - $repository = new NotationsRepository( $transformer );
94 - $labels = $repository->get_labels( 'post', $post_id );
95 -
96 - $labels_repo = new LabelsRepository;
97 - $labels_transformer = new LabelsTransformer( $labels_repo );
98 - $terms = $labels_repo->query( [ 'hide_empty' => false ] )->get_terms();
99 -
100 - // Assemble term meta dataset
101 - $term_meta = [];
102 - foreach ( $terms as $key => $term ) {
103 - $item = call_user_func( $labels_transformer, $term );
104 - $term_meta[ $item['id'] ] = $item;
105 - }
106 -
107 - // Output labels
108 - foreach ( $labels as $label ) {
109 - $term = $term_meta[ $label['label_id'] ];
110 - if ( isset( $term ) ) {
111 - print "<span style='{$styles}'><span style='{$dot}; background-color: {$term['color']}'></span>{$term['label']}</span>";
112 - }
113 - }
114 - }
87 + add_filter( 'script_loader_tag', $this->injector->make( OnScriptLoaderTag::class ), 10, 3 );
115 88 }
116 89 }