column
12 years ago
storage_model
12 years ago
addons.php
12 years ago
column.php
12 years ago
settings.php
12 years ago
storage_model.php
12 years ago
third_party.php
12 years ago
upgrade.php
12 years ago
utility.php
12 years ago
third_party.php
163 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Fix for getting the columns loaded by WordPress SEO Yoast |
| 5 | * |
| 6 | * The added columns from WordPress SEO by Yoast weren't available on |
| 7 | * the admin columns settings page. The reason was that class-metabox.php was prevented |
| 8 | * from loading. This fix will also load this class when admin columns is loaded. |
| 9 | * |
| 10 | * @since 1.4.6 |
| 11 | */ |
| 12 | function cpac_pre_load_wordpress_seo_class_metabox() { |
| 13 | global $pagenow; |
| 14 | |
| 15 | if ( defined('WPSEO_PATH') && file_exists(WPSEO_PATH.'admin/class-metabox.php') ) { |
| 16 | if ( |
| 17 | ( isset($_GET['page']) && 'codepress-admin-columns' == $_GET['page'] && 'options-general.php' == $pagenow ) |
| 18 | || |
| 19 | // for when column list is populated through ajax |
| 20 | ( defined('DOING_AJAX') && DOING_AJAX && ! empty( $_POST['type'] ) ) |
| 21 | ) { |
| 22 | require_once WPSEO_PATH.'admin/class-metabox.php'; |
| 23 | if ( class_exists( 'WPSEO_Metabox' ) ) { |
| 24 | new WPSEO_Metabox; |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | add_action( 'plugins_loaded', 'cpac_pre_load_wordpress_seo_class_metabox', 0 ); |
| 30 | |
| 31 | /** |
| 32 | * WPML compatibility |
| 33 | * |
| 34 | * @since 2.0 |
| 35 | */ |
| 36 | function cac_add_wpml_columns( $storage_model ) { |
| 37 | |
| 38 | if( ! class_exists('SitePress') ) return; |
| 39 | |
| 40 | global $pagenow; |
| 41 | |
| 42 | // only for posts |
| 43 | if ( 'options-general.php' !== $pagenow || 'post' !== $storage_model->type ) return; |
| 44 | |
| 45 | global $sitepress, $posts, $__management_columns_posts_translations; |
| 46 | |
| 47 | // prevent DB error |
| 48 | $__management_columns_posts_translations = 'not_null'; |
| 49 | |
| 50 | $post_type = $storage_model->key; |
| 51 | |
| 52 | // Is needed by SitePress::add_posts_management_column() |
| 53 | $posts = get_posts( array( |
| 54 | 'post_type' => $post_type, |
| 55 | 'numberposts' => -1 |
| 56 | )); |
| 57 | |
| 58 | // Trigger SitePress::add_posts_management_column() so admin coumkns can pick up it's added column heading |
| 59 | add_filter( "manage_{$post_type}s_columns", array( $sitepress, 'add_posts_management_column' ) ); |
| 60 | } |
| 61 | add_action( 'cac/get_columns', 'cac_add_wpml_columns' ); |
| 62 | |
| 63 | /** |
| 64 | * Fix which remove the Advanced Custom Fields Type (acf) from the admin columns settings page |
| 65 | * |
| 66 | * @since 2.0 |
| 67 | * |
| 68 | * @return array Posttypes |
| 69 | */ |
| 70 | function cpac_remove_acf_from_cpac_post_types( $post_types ) { |
| 71 | if ( class_exists('Acf') ) { |
| 72 | unset( $post_types['acf'] ); |
| 73 | unset( $post_types['acf-field-group'] ); |
| 74 | } |
| 75 | |
| 76 | return $post_types; |
| 77 | } |
| 78 | add_filter( 'cac/post_types', 'cpac_remove_acf_from_cpac_post_types' ); |
| 79 | |
| 80 | /** |
| 81 | * bbPress - remove posttypes: forum, reply and topic |
| 82 | * |
| 83 | * @since 2.0 |
| 84 | * |
| 85 | * @return array Posttypes |
| 86 | */ |
| 87 | function cpac_posttypes_remove_bbpress( $post_types ) { |
| 88 | if ( class_exists( 'bbPress' ) ) { |
| 89 | unset( $post_types['topic'] ); |
| 90 | unset( $post_types['reply'] ); |
| 91 | unset( $post_types['forum'] ); |
| 92 | } |
| 93 | |
| 94 | return $post_types; |
| 95 | } |
| 96 | add_filter( 'cac/post_types', 'cpac_posttypes_remove_bbpress' ); |
| 97 | |
| 98 | /** |
| 99 | * Add support for All in SEO columns |
| 100 | * |
| 101 | * @since 2.0 |
| 102 | */ |
| 103 | function cpac_load_aioseop_addmycolumns() { |
| 104 | if ( function_exists('aioseop_addmycolumns') ) { |
| 105 | aioseop_addmycolumns(); |
| 106 | } |
| 107 | } |
| 108 | add_action( 'cac/columns/default/posts', 'cpac_load_aioseop_addmycolumns' ); |
| 109 | |
| 110 | /** |
| 111 | * WPML Register labels |
| 112 | * |
| 113 | * To enable the translation of the column labels |
| 114 | * |
| 115 | * @since 2.0 |
| 116 | */ |
| 117 | function cpac_wpml_register_column_labels() { |
| 118 | global $cpac; |
| 119 | |
| 120 | // dont load this unless required by WPML |
| 121 | if ( !isset( $_GET['page'] ) || 'wpml-string-translation/menu/string-translation.php' !== $_GET['page'] ) return; |
| 122 | |
| 123 | foreach ( $cpac->storage_models as $storage_model ) { |
| 124 | foreach ( $storage_model->get_stored_columns() as $column_name => $options ) { |
| 125 | icl_register_string( 'Admin Columns', $storage_model->key . '_' . $column_name, stripslashes( $options['label'] ) ); |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | add_action( 'wp_loaded', 'cpac_wpml_register_column_labels', 99 ); |
| 130 | |
| 131 | /** |
| 132 | * WPML Display translated label |
| 133 | * |
| 134 | * @since 2.0 |
| 135 | */ |
| 136 | function cpac_wpml_set_translated_label( $label, $column_name, $column_options, $storage_model ) { |
| 137 | |
| 138 | // register with WPML |
| 139 | if( function_exists('icl_t') ) { |
| 140 | $name = $storage_model->key . '_' . $column_name; |
| 141 | $label = icl_t( 'Admin Columns', $name, $label ); |
| 142 | } |
| 143 | |
| 144 | return $label; |
| 145 | } |
| 146 | add_filter( 'cac/headings/label', 'cpac_wpml_set_translated_label', 10, 4 ); |
| 147 | |
| 148 | /** |
| 149 | * Set WPML to be a columns screen for translation so that storage models are loaded |
| 150 | * |
| 151 | * @since 2.2 |
| 152 | */ |
| 153 | function cpac_wpml_is_cac_screen( $is_columns_screen ) { |
| 154 | |
| 155 | if ( isset( $_GET['page'] ) && $_GET['page'] == 'wpml-string-translation/menu/string-translation.php' ) { |
| 156 | return true; |
| 157 | } |
| 158 | |
| 159 | return $is_columns_screen; |
| 160 | } |
| 161 | |
| 162 | add_filter( 'cac/is_cac_screen', 'cpac_wpml_is_cac_screen' ); |
| 163 |