PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.3.0
Forumax – AI Powered Advanced Community Forum Plugin v1.3.0
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / includes / features / bbpc_attachments / code / meta.php

meta.php in Forumax – AI Powered Advanced Community Forum Plugin 1.3.0, at includes/features/bbpc_attachments/code/meta.php

153 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class GDATTAdminMeta {
8 function __construct() {
9 add_action( 'after_setup_theme', [ $this, 'load' ], 10 );
10 }
11
12 public function load() {
13 add_action( 'admin_init', [ $this, 'admin_init' ] );
14 add_action( 'admin_menu', [ $this, 'admin_meta' ] );
15 add_action( 'admin_head', [ $this, 'admin_head' ] );
16
17 add_action( 'save_post', [ $this, 'save_edit_forum' ] );
18
19 add_action( 'manage_topic_posts_columns', [ $this, 'admin_post_columns' ], 1000 );
20 add_action( 'manage_reply_posts_columns', [ $this, 'admin_post_columns' ], 1000 );
21
22 add_action( 'manage_topic_posts_custom_column', [ $this, 'admin_columns_data' ], 1000, 2 );
23 add_action( 'manage_reply_posts_custom_column', [ $this, 'admin_columns_data' ], 1000, 2 );
24 }
25
26 public static function instance() {
27 static $instance = false;
28
29 if ( $instance === false ) {
30 $instance = new GDATTAdminMeta();
31 }
32
33 return $instance;
34 }
35
36 public function admin_init() {
37 if ( isset( $_POST['gdbb-attach-submit'] ) ) {
38
39 check_admin_referer( 'bbp-core' );
40
41 //TODO: Check all these.
42 BBPCATTCore::instance()->o['max_file_size'] = absint( $_POST['max_file_size'] );
43 BBPCATTCore::instance()->o['max_to_upload'] = absint( $_POST['max_to_upload'] );
44 BBPCATTCore::instance()->o['roles_to_upload'] = (array) $_POST['roles_to_upload'];
45 BBPCATTCore::instance()->o['is_attachment_icon'] = isset( $_POST['is_attachment_icon'] ) ? 1 : 0;
46 BBPCATTCore::instance()->o['is_attachment_icons'] = isset( $_POST['is_attachment_icons'] ) ? 1 : 0;
47 BBPCATTCore::instance()->o['hide_from_visitors'] = isset( $_POST['hide_from_visitors'] ) ? 1 : 0;
48 BBPCATTCore::instance()->o['include_always'] = isset( $_POST['include_always'] ) ? 1 : 0;
49 BBPCATTCore::instance()->o['delete_attachments'] = bbpc_sanitize_basic( $_POST['delete_attachments'] );
50
51 update_option( 'bbp-core', BBPCATTCore::instance()->o );
52 wp_redirect( esc_url_raw( add_query_arg( 'settings-updated', 'true' ) ) );
53 exit();
54 }
55
56 if ( isset( $_POST['gdbb-att-advanced-submit'] ) ) {
57 check_admin_referer( 'bbp-core' );
58
59 BBPCATTCore::instance()->o['log_upload_errors'] = isset( $_POST['log_upload_errors'] ) ? 1 : 0;
60 BBPCATTCore::instance()->o['errors_visible_to_admins'] = isset( $_POST['errors_visible_to_admins'] ) ? 1 : 0;
61 BBPCATTCore::instance()->o['errors_visible_to_moderators'] = isset( $_POST['errors_visible_to_moderators'] ) ? 1 : 0;
62 BBPCATTCore::instance()->o['errors_visible_to_author'] = isset( $_POST['errors_visible_to_author'] ) ? 1 : 0;
63 BBPCATTCore::instance()->o['delete_visible_to_admins'] = true; //TODO: Customize in pro version
64 BBPCATTCore::instance()->o['delete_visible_to_moderators'] = true; //TODO: Customize in pro version
65 BBPCATTCore::instance()->o['delete_visible_to_author'] = false; //TODO: Customize in pro version
66
67 update_option( 'bbp-core', BBPCATTCore::instance()->o );
68 wp_redirect( esc_url_raw( add_query_arg( 'settings-updated', 'true' ) ) );
69 exit();
70 }
71 }
72
73 public function admin_head() { ?>
74 <style type="text/css">
75 /*<![CDATA[*/
76 th.column-gdbbatt_count,
77 td.column-gdbbatt_count {
78 width: 3%;
79 text-align: center;
80 }
81 /*]]>*/
82 </style>
83 <?php
84 }
85
86 public function save_edit_forum( $post_id ) {
87 if ( isset( $_POST['post_ID'] ) && $_POST['post_ID'] > 0 ) {
88 $post_id = $_POST['post_ID'];
89 }
90
91 if ( isset( $_POST['gdbbatt_forum_meta'] ) && $_POST['gdbbatt_forum_meta'] == 'edit' ) {
92 $data = (array) $_POST['gdbbatt'];
93 $meta = [
94 'disable' => isset( $data['disable'] ) ? 1 : 0,
95 'to_override' => isset( $data['to_override'] ) ? 1 : 0,
96 'hide_from_visitors' => isset( $data['hide_from_visitors'] ) ? 1 : 0,
97 'max_file_size' => absint( $data['max_file_size'] ),
98 'max_to_upload' => absint( $data['max_to_upload'] ),
99 ];
100
101 update_post_meta( $post_id, '_gdbbatt_settings', $meta );
102 }
103 }
104
105 public function admin_post_columns( $columns ) {
106 $columns['gdbbatt_count'] = '<img src="' . BBPCATTACHMENT_URL . 'css/gfx/attachment.png" width="16" height="12" alt="' . __( 'Attachments', 'bbp-core' ) . '" title="' . __( 'Attachments', 'bbp-core' ) . '" />';
107
108 return $columns;
109 }
110
111 public function admin_columns_data( $column, $id ) {
112 if ( $column == 'gdbbatt_count' ) {
113 $attachments = bbpc_get_post_attachments( $id );
114 echo count( $attachments );
115 }
116 }
117
118 public function admin_meta() {
119 if ( current_user_can( BBPC_ATTACHMENT ) ) {
120 add_meta_box( 'gdbbattach-meta-forum', __( 'Attachments Settings', 'bbp-core' ), [ $this, 'metabox_forum' ], 'forum', 'side', 'high' );
121 add_meta_box( 'gdbbattach-meta-files', __( 'Attachments List', 'bbp-core' ), [ $this, 'metabox_files' ], 'topic', 'side', 'high' );
122 add_meta_box( 'gdbbattach-meta-files', __( 'Attachments List', 'bbp-core' ), [ $this, 'metabox_files' ], 'reply', 'side', 'high' );
123 }
124 }
125
126 public function metabox_forum() {
127 global $post_ID;
128
129 $meta = get_post_meta( $post_ID, '_gdbbatt_settings', true );
130 if ( ! is_array( $meta ) ) {
131
132 $meta = [
133 'disable' => 0,
134 'to_override' => 0,
135 'hide_from_visitors' => 1,
136 'max_file_size' => BBPCATTCore::instance()->get_file_size( true ),
137 'max_to_upload' => BBPCATTCore::instance()->get_max_files( true ),
138 ];
139 }
140
141 include BBPCATTACHMENTS_PATH . 'forms/attachments/meta_forum.php';
142 }
143
144 public function metabox_files() {
145 global $post_ID, $user_ID;
146
147 $post = get_post( $post_ID );
148 $author_id = $post->post_author;
149
150 include BBPCATTACHMENTS_PATH . 'forms/attachments/meta_files.php';
151 }
152 }
153