column
12 years ago
storage_model
12 years ago
api.php
12 years ago
column.php
12 years ago
deprecated.php
12 years ago
export_import.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
145 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 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 | } |
| 24 | } |
| 25 | } |
| 26 | add_action( 'plugins_loaded', 'pre_load_wordpress_seo_class_metabox', 0 ); |
| 27 | |
| 28 | /** |
| 29 | * WPML compatibility |
| 30 | * |
| 31 | * @since 2.0.0 |
| 32 | */ |
| 33 | function cac_add_wpml_columns( $storage_model ) { |
| 34 | |
| 35 | if( ! class_exists('SitePress') ) return; |
| 36 | |
| 37 | global $pagenow; |
| 38 | |
| 39 | // only for posts |
| 40 | if ( 'options-general.php' !== $pagenow || 'post' !== $storage_model->type ) return; |
| 41 | |
| 42 | global $sitepress, $posts, $__management_columns_posts_translations; |
| 43 | |
| 44 | // prevent DB error |
| 45 | $__management_columns_posts_translations = 'not_null'; |
| 46 | |
| 47 | $post_type = $storage_model->key; |
| 48 | |
| 49 | // Is needed by SitePress::add_posts_management_column() |
| 50 | $posts = get_posts( array( |
| 51 | 'post_type' => $post_type, |
| 52 | 'numberposts' => -1 |
| 53 | )); |
| 54 | |
| 55 | // Trigger SitePress::add_posts_management_column() so admin coumkns can pick up it's added column heading |
| 56 | add_filter( "manage_{$post_type}s_columns", array( $sitepress, 'add_posts_management_column' ) ); |
| 57 | } |
| 58 | add_action( 'cac/get_columns', 'cac_add_wpml_columns' ); |
| 59 | |
| 60 | /** |
| 61 | * Fix which remove the Advanced Custom Fields Type (acf) from the admin columns settings page |
| 62 | * |
| 63 | * @since 2.0.0 |
| 64 | * |
| 65 | * @return array Posttypes |
| 66 | */ |
| 67 | function remove_acf_from_cpac_post_types( $post_types ) { |
| 68 | if ( class_exists('Acf') ) { |
| 69 | unset( $post_types['acf'] ); |
| 70 | } |
| 71 | |
| 72 | return $post_types; |
| 73 | } |
| 74 | add_filter( 'cac/post_types', 'remove_acf_from_cpac_post_types' ); |
| 75 | |
| 76 | /** |
| 77 | * bbPress - remove posttypes: forum, reply and topic |
| 78 | * |
| 79 | * @since 2.0.0 |
| 80 | * |
| 81 | * @return array Posttypes |
| 82 | */ |
| 83 | function cpac_posttypes_remove_bbpress( $post_types ) { |
| 84 | if ( class_exists( 'bbPress' ) ) { |
| 85 | unset( $post_types['topic'] ); |
| 86 | unset( $post_types['reply'] ); |
| 87 | unset( $post_types['forum'] ); |
| 88 | } |
| 89 | |
| 90 | return $post_types; |
| 91 | } |
| 92 | add_filter( 'cac/post_types', 'cpac_posttypes_remove_bbpress' ); |
| 93 | |
| 94 | /** |
| 95 | * Add support for All in SEO columns |
| 96 | * |
| 97 | * @since 2.0.0 |
| 98 | */ |
| 99 | function cpac_load_aioseop_addmycolumns() { |
| 100 | if ( function_exists('aioseop_addmycolumns') ) { |
| 101 | aioseop_addmycolumns(); |
| 102 | } |
| 103 | } |
| 104 | add_action( 'cac/columns/default/posts', 'cpac_load_aioseop_addmycolumns' ); |
| 105 | |
| 106 | /** |
| 107 | * WPML Register labels |
| 108 | * |
| 109 | * To enable the translation of the column labels |
| 110 | * |
| 111 | * @since 2.0.0 |
| 112 | */ |
| 113 | function cpac_wpml_register_column_labels() { |
| 114 | global $cpac; |
| 115 | |
| 116 | // dont load this unless required by WPML |
| 117 | if ( !isset( $_GET['page'] ) || 'wpml-string-translation/menu/string-translation.php' !== $_GET['page'] ) return; |
| 118 | |
| 119 | foreach ( $cpac->storage_models as $storage_model ) { |
| 120 | foreach ( $storage_model->get_stored_columns() as $column_name => $options ) { |
| 121 | icl_register_string( 'Admin Columns', $storage_model->key . '_' . $column_name, stripslashes( $options['label'] ) ); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | add_action( 'wp_loaded', 'cpac_wpml_register_column_labels', 99 ); |
| 126 | |
| 127 | /** |
| 128 | * WPML Display translated label |
| 129 | * |
| 130 | * @since 2.0.0 |
| 131 | */ |
| 132 | function cpac_wpml_set_translated_label( $label, $column_name, $column_options, $storage_model ) { |
| 133 | |
| 134 | // register with WPML |
| 135 | if( function_exists('icl_t') ) { |
| 136 | $name = $storage_model->key . '_' . $column_name; |
| 137 | $label = icl_t( 'Admin Columns', $name, $label ); |
| 138 | } |
| 139 | |
| 140 | return $label; |
| 141 | } |
| 142 | add_filter( 'cac/headings/label', 'cpac_wpml_set_translated_label', 10, 4 ); |
| 143 | |
| 144 | |
| 145 |