diff --git a/add-language-page.php b/add-language-page.php index 2c1b812..558e973 100644 --- a/add-language-page.php +++ b/add-language-page.php @@ -1,4 +1,13 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class Multilingual_WP_Add_Language_Page extends scb_MLWP_AdminPage { protected $admin_notice = false; diff --git a/class-mlwp-comment-query.php b/class-mlwp-comment-query.php index fa23680..57ebb24 100644 --- a/class-mlwp-comment-query.php +++ b/class-mlwp-comment-query.php @@ -1,18 +1,27 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ /** * WordPress Comment Query class + WP_Meta_Query. * * The default Wordpress Comment Query class with added compatibility for meta queries :) + * It's deprecated since WordPress 3.5 - when a native meta_query support has been introduced * - * @since 3.1.0 - * @deprecated 3.5 - uses WP's version since it has meta_query support since WP 3.5 + * @package Multilingual WP + * @since 0.1 */ class MLWP_Comment_Query extends WP_Comment_Query { /** * Metadata query container * - * @since 3.2.0 * @access public * @var object WP_Meta_Query */ @@ -21,8 +30,6 @@ class MLWP_Comment_Query extends WP_Comment_Query { /** * Execute the query * - * @since 3.1.0 - * * @param string|array $query_vars * @return int|array */ diff --git a/class-mlwp-gsmg.php b/class-mlwp-gsmg.php index 22e314a..0dfc93a 100644 --- a/class-mlwp-gsmg.php +++ b/class-mlwp-gsmg.php @@ -1,14 +1,29 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ /** * */ class MLWP_GSMG extends GoogleSitemapGeneratorStandardBuilder { /** - * Override the default construct method for GoogleSitemapGeneratorStandardBuilder - * - * This way we add our actions with higher(lower index) priority, so then we can remove the default actions in MLWP_GSMG::remove_def_actions() - **/ + * Override the default construct method for GoogleSitemapGeneratorStandardBuilder + * + * This way we add our actions with higher(lower index) priority, + * so then we can remove the default actions in MLWP_GSMG::remove_def_actions() + */ function __construct() { add_action( "sm_build_index", array( $this, "language_index" ), 1, 1 ); add_action( "sm_build_content", array( $this, "language_content" ), 1, 3 ); @@ -19,9 +34,11 @@ function __construct() { /** * Removes the default actions added by GoogleSitemapGeneratorStandardBuilder::__construct() * - * By removing the default actions, we make sure that there won't be duplication issues. Also we make sure to only remove - * the GoogleSitemapGeneratorStandardBuilder::Index() and GoogleSitemapGeneratorStandardBuilder::Content() functions - **/ + * By removing the default actions, we make sure that there + * won't be duplication issues. Also we make sure to only remove + * the GoogleSitemapGeneratorStandardBuilder::Index() + * and GoogleSitemapGeneratorStandardBuilder::Content() functions + */ private function remove_def_actions() { global $wp_filter; diff --git a/credits-page.php b/credits-page.php index 9da5daf..a1715b4 100644 --- a/credits-page.php +++ b/credits-page.php @@ -1,4 +1,13 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class Multilingual_WP_Credits_Page extends scb_MLWP_AdminPage { protected $admin_notice = false; diff --git a/css/multilingual-wp-settings.css b/css/multilingual-wp-settings.css index 6344b3f..4d4d163 100644 --- a/css/multilingual-wp-settings.css +++ b/css/multilingual-wp-settings.css @@ -27,5 +27,7 @@ div.mlwp-box.mlwp-error { background-color: #FFCACA; border-color: #F33636; font /* Screen Icons */ -.multilingual-wp_page_add-new-language .wrap h2 { line-height: 51px; } -#icon-mlwp_add_language { background-image: url(../images/add-language-icon.png); width: 64px; height: 50px; margin-right: 12px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } \ No newline at end of file +.multilingual-wp_page_add-new-language .wrap h2, +.multilingual-wp_page_remove-a-language .wrap h2 { line-height: 51px; } +#icon-mlwp_add_language { background-image: url(../images/add-language-icon.png); width: 64px; height: 50px; margin-right: 12px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } +#icon-mlwp_remove_language { background-image: url(../images/remove-language-icon.png); width: 64px; height: 50px; margin-right: 12px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } \ No newline at end of file diff --git a/flags_data.php b/flags_data.php index 5ac8c07..1cd075b 100644 --- a/flags_data.php +++ b/flags_data.php @@ -1,14 +1,26 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ -/* - Contains all supported flags. Key is the name of the flag icon and value is the label(usually country) corresponding for that icon. -*/ global $MULTILINGUAL_WP_FLAGS; -/* - All country names will be passed through ucwords(), so it's not necessary to translate them with an uppercase first character -*/ - +/** + * + * Contains all supported flags. + * + * Key is the name of the flag icon and value is the label(usually country), + * corresponding for that icon. All country names will be passed through ucwords(), + * so it's not necessary to translate them with an uppercase first character + * + * @var array $MULTILINGUAL_WP_FLAGS + */ $MULTILINGUAL_WP_FLAGS = array( 'afghanistan.png' => __( 'afghanistan', 'multilingual-wp' ), 'aland-islands.png' => __( 'aland islands', 'multilingual-wp' ), 'albania.png' => __( 'albania', 'multilingual-wp' ), 'algeria.png' => __( 'algeria', 'multilingual-wp' ), 'american-samoa.png' => __( 'american samoa', 'multilingual-wp' ), 'andorra.png' => __( 'andorra', 'multilingual-wp' ), 'angola.png' => __( 'angola', 'multilingual-wp' ), 'anguilla.png' => __( 'anguilla', 'multilingual-wp' ), 'antarctica.png' => __( 'antarctica', 'multilingual-wp' ), 'antigua-and-barbuda.png' => __( 'antigua and barbuda', 'multilingual-wp' ), 'argentina.png' => __( 'argentina', 'multilingual-wp' ), 'armenia.png' => __( 'armenia', 'multilingual-wp' ), 'aruba.png' => __( 'aruba', 'multilingual-wp' ), 'australia.png' => __( 'australia', 'multilingual-wp' ), 'austria.png' => __( 'austria', 'multilingual-wp' ), 'azerbaijan.png' => __( 'azerbaijan', 'multilingual-wp' ), 'bahamas.png' => __( 'bahamas', 'multilingual-wp' ), 'bahrain.png' => __( 'bahrain', 'multilingual-wp' ), 'bangladesh.png' => __( 'bangladesh', 'multilingual-wp' ), 'barbados.png' => __( 'barbados', 'multilingual-wp' ), 'belarus.png' => __( 'belarus', 'multilingual-wp' ), 'belgium.png' => __( 'belgium', 'multilingual-wp' ), 'belize.png' => __( 'belize', 'multilingual-wp' ), 'benin.png' => __( 'benin', 'multilingual-wp' ), 'bermuda.png' => __( 'bermuda', 'multilingual-wp' ), 'bhutan.png' => __( 'bhutan', 'multilingual-wp' ), 'biot.png' => __( 'biot', 'multilingual-wp' ), 'bolivia.png' => __( 'bolivia', 'multilingual-wp' ), 'bosnian.png' => __( 'bosnian', 'multilingual-wp' ), 'botswana.png' => __( 'botswana', 'multilingual-wp' ), 'bouvet-island.png' => __( 'bouvet island', 'multilingual-wp' ), 'brazil.png' => __( 'brazil', 'multilingual-wp' ), 'british-antarctic-territory.png' => __( 'british antarctic territory', 'multilingual-wp' ), 'british-virgin-islands.png' => __( 'british virgin islands', 'multilingual-wp' ), 'brunei.png' => __( 'brunei', 'multilingual-wp' ), 'bulgaria.png' => __( 'bulgaria', 'multilingual-wp' ), 'burkina-faso.png' => __( 'burkina faso', 'multilingual-wp' ), 'burma.png' => __( 'burma', 'multilingual-wp' ), 'burundi.png' => __( 'burundi', 'multilingual-wp' ), 'cambodia.png' => __( 'cambodia', 'multilingual-wp' ), 'cameroon.png' => __( 'cameroon', 'multilingual-wp' ), 'canada.png' => __( 'canada', 'multilingual-wp' ), 'cape-verde.png' => __( 'cape verde', 'multilingual-wp' ), 'cayman-islands.png' => __( 'cayman islands', 'multilingual-wp' ), 'centralafricanrepublic.png' => __( 'centralafricanrepublic', 'multilingual-wp' ), 'chad.png' => __( 'chad', 'multilingual-wp' ), 'chile.png' => __( 'chile', 'multilingual-wp' ), 'china.png' => __( 'china', 'multilingual-wp' ), 'christmas-island.png' => __( 'christmas island', 'multilingual-wp' ), 'cocos-islands.png' => __( 'cocos islands', 'multilingual-wp' ), 'colombia.png' => __( 'colombia', 'multilingual-wp' ), 'comoros.png' => __( 'comoros', 'multilingual-wp' ), 'congo-kinshasa.png' => __( 'congo kinshasa', 'multilingual-wp' ), 'congo.png' => __( 'congo', 'multilingual-wp' ), 'cook-islands.png' => __( 'cook islands', 'multilingual-wp' ), 'costa-rica.png' => __( 'costa rica', 'multilingual-wp' ), 'croatian.png' => __( 'croatian', 'multilingual-wp' ), 'cuba.png' => __( 'cuba', 'multilingual-wp' ), 'cyprus.png' => __( 'cyprus', 'multilingual-wp' ), 'czech-republic.png' => __( 'czech republic', 'multilingual-wp' ), 'denmark.png' => __( 'denmark', 'multilingual-wp' ), 'djibouti.png' => __( 'djibouti', 'multilingual-wp' ), 'dominicana.png' => __( 'dominicana', 'multilingual-wp' ), 'dominican-republic.png' => __( 'dominican republic', 'multilingual-wp' ), 'east-timor.png' => __( 'east timor', 'multilingual-wp' ), 'ecuador.png' => __( 'ecuador', 'multilingual-wp' ), 'egypt.png' => __( 'egypt', 'multilingual-wp' ), 'el-salvador.png' => __( 'el salvador', 'multilingual-wp' ), 'england.png' => __( 'england', 'multilingual-wp' ), 'equatorial-guinea.png' => __( 'equatorial guinea', 'multilingual-wp' ), 'eritrea.png' => __( 'eritrea', 'multilingual-wp' ), 'estonia.png' => __( 'estonia', 'multilingual-wp' ), 'ethiopia.png' => __( 'ethiopia', 'multilingual-wp' ), 'european-union.png' => __( 'european union', 'multilingual-wp' ), 'ex-yugoslavia.png' => __( 'ex yugoslavia', 'multilingual-wp' ), 'falkland-islands.png' => __( 'falkland islands', 'multilingual-wp' ), 'faroe-islands.png' => __( 'faroe islands', 'multilingual-wp' ), 'fiji.png' => __( 'fiji', 'multilingual-wp' ), 'finland.png' => __( 'finland', 'multilingual-wp' ), 'france.png' => __( 'france', 'multilingual-wp' ), 'french-polynesia.png' => __( 'french polynesia', 'multilingual-wp' ), 'french-southern-territories.png' => __( 'french southern territories', 'multilingual-wp' ), 'gabon.png' => __( 'gabon', 'multilingual-wp' ), 'gambia.png' => __( 'gambia', 'multilingual-wp' ), 'georgia.png' => __( 'georgia', 'multilingual-wp' ), 'germany.png' => __( 'germany', 'multilingual-wp' ), 'ghana.png' => __( 'ghana', 'multilingual-wp' ), 'gibraltar.png' => __( 'gibraltar', 'multilingual-wp' ), 'greece.png' => __( 'greece', 'multilingual-wp' ), 'greenland.png' => __( 'greenland', 'multilingual-wp' ), 'grenada.png' => __( 'grenada', 'multilingual-wp' ), 'guadeloupe.png' => __( 'guadeloupe', 'multilingual-wp' ), 'guam.png' => __( 'guam', 'multilingual-wp' ), 'guatemala.png' => __( 'guatemala', 'multilingual-wp' ), 'guernsey.png' => __( 'guernsey', 'multilingual-wp' ), 'guinea-bissau.png' => __( 'guinea bissau', 'multilingual-wp' ), 'guinea.png' => __( 'guinea', 'multilingual-wp' ), 'guyana.png' => __( 'guyana', 'multilingual-wp' ), 'haiti.png' => __( 'haiti', 'multilingual-wp' ), 'holy-see.png' => __( 'holy see', 'multilingual-wp' ), 'honduras.png' => __( 'honduras', 'multilingual-wp' ), 'hong-kong.png' => __( 'hong kong', 'multilingual-wp' ), 'hungary.png' => __( 'hungary', 'multilingual-wp' ), 'iceland.png' => __( 'iceland', 'multilingual-wp' ), 'india.png' => __( 'india', 'multilingual-wp' ), 'indonesia.png' => __( 'indonesia', 'multilingual-wp' ), 'iran.png' => __( 'iran', 'multilingual-wp' ), 'iraq.png' => __( 'iraq', 'multilingual-wp' ), 'ireland.png' => __( 'ireland', 'multilingual-wp' ), 'isle-of-man.png' => __( 'isle of man', 'multilingual-wp' ), 'israel.png' => __( 'israel', 'multilingual-wp' ), 'italy.png' => __( 'italy', 'multilingual-wp' ), 'ivory-coast.png' => __( 'ivory coast', 'multilingual-wp' ), 'jamaica.png' => __( 'jamaica', 'multilingual-wp' ), 'jan-mayen.png' => __( 'jan mayen', 'multilingual-wp' ), 'japan.png' => __( 'japan', 'multilingual-wp' ), 'jarvis-island.png' => __( 'jarvis island', 'multilingual-wp' ), 'jersey.png' => __( 'jersey', 'multilingual-wp' ), 'jordan.png' => __( 'jordan', 'multilingual-wp' ), 'kazakhstan.png' => __( 'kazakhstan', 'multilingual-wp' ), 'kenya.png' => __( 'kenya', 'multilingual-wp' ), 'kiribati.png' => __( 'kiribati', 'multilingual-wp' ), 'korea.png' => __( 'korea', 'multilingual-wp' ), 'kosovo.png' => __( 'kosovo', 'multilingual-wp' ), 'kuwait.png' => __( 'kuwait', 'multilingual-wp' ), 'kyrgyzstan.png' => __( 'kyrgyzstan', 'multilingual-wp' ), 'laos.png' => __( 'laos', 'multilingual-wp' ), 'latvia.png' => __( 'latvia', 'multilingual-wp' ), 'lebanon.png' => __( 'lebanon', 'multilingual-wp' ), 'lesotho.png' => __( 'lesotho', 'multilingual-wp' ), 'liberia.png' => __( 'liberia', 'multilingual-wp' ), 'libya.png' => __( 'libya', 'multilingual-wp' ), 'liechtenstein.png' => __( 'liechtenstein', 'multilingual-wp' ), 'lithuania.png' => __( 'lithuania', 'multilingual-wp' ), 'luxembourg.png' => __( 'luxembourg', 'multilingual-wp' ), 'macau.png' => __( 'macau', 'multilingual-wp' ), 'macedonia.png' => __( 'macedonia', 'multilingual-wp' ), 'madagascar.png' => __( 'madagascar', 'multilingual-wp' ), 'malawi.png' => __( 'malawi', 'multilingual-wp' ), 'malaysia.png' => __( 'malaysia', 'multilingual-wp' ), 'maldives.png' => __( 'maldives', 'multilingual-wp' ), 'mali.png' => __( 'mali', 'multilingual-wp' ), 'malta.png' => __( 'malta', 'multilingual-wp' ), 'marshall-islands.png' => __( 'marshall islands', 'multilingual-wp' ), 'martinique.png' => __( 'martinique', 'multilingual-wp' ), 'mauritania.png' => __( 'mauritania', 'multilingual-wp' ), 'mauritius.png' => __( 'mauritius', 'multilingual-wp' ), 'mayotte.png' => __( 'mayotte', 'multilingual-wp' ), 'mexico.png' => __( 'mexico', 'multilingual-wp' ), 'micronesia.png' => __( 'micronesia', 'multilingual-wp' ), 'moldova.png' => __( 'moldova', 'multilingual-wp' ), 'monaco.png' => __( 'monaco', 'multilingual-wp' ), 'mongolia.png' => __( 'mongolia', 'multilingual-wp' ), 'montenegro.png' => __( 'montenegro', 'multilingual-wp' ), 'montserrat.png' => __( 'montserrat', 'multilingual-wp' ), 'morocco.png' => __( 'morocco', 'multilingual-wp' ), 'mozambique.png' => __( 'mozambique', 'multilingual-wp' ), 'myanmar.png' => __( 'myanmar', 'multilingual-wp' ), 'namibia.png' => __( 'namibia', 'multilingual-wp' ), 'nauru.png' => __( 'nauru', 'multilingual-wp' ), 'nepal.png' => __( 'nepal', 'multilingual-wp' ), 'netherlands-antilles.png' => __( 'netherlands antilles', 'multilingual-wp' ), 'netherlands.png' => __( 'netherlands', 'multilingual-wp' ), 'new-caledonia.png' => __( 'new caledonia', 'multilingual-wp' ), 'new-zealand.png' => __( 'new zealand', 'multilingual-wp' ), 'nicaragua.png' => __( 'nicaragua', 'multilingual-wp' ), 'nigeria.png' => __( 'nigeria', 'multilingual-wp' ), 'niger.png' => __( 'niger', 'multilingual-wp' ), 'niue.png' => __( 'niue', 'multilingual-wp' ), 'norfolk-island.png' => __( 'norfolk island', 'multilingual-wp' ), 'northern-ireland.png' => __( 'northern ireland', 'multilingual-wp' ), 'northern-mariana-islands.png' => __( 'northern mariana islands', 'multilingual-wp' ), 'north-korea.png' => __( 'north korea', 'multilingual-wp' ), 'norway.png' => __( 'norway', 'multilingual-wp' ), 'oman.png' => __( 'oman', 'multilingual-wp' ), 'pakistan.png' => __( 'pakistan', 'multilingual-wp' ), 'palau.png' => __( 'palau', 'multilingual-wp' ), 'palestinian-territory.png' => __( 'palestinian territory', 'multilingual-wp' ), 'panama.png' => __( 'panama', 'multilingual-wp' ), 'papua-new-guinea.png' => __( 'papua new guinea', 'multilingual-wp' ), 'paraguay.png' => __( 'paraguay', 'multilingual-wp' ), 'peru.png' => __( 'peru', 'multilingual-wp' ), 'philippines.png' => __( 'philippines', 'multilingual-wp' ), 'pitcairn.png' => __( 'pitcairn', 'multilingual-wp' ), 'poland.png' => __( 'poland', 'multilingual-wp' ), 'portugal.png' => __( 'portugal', 'multilingual-wp' ), 'puerto-rico.png' => __( 'puerto rico', 'multilingual-wp' ), 'qatar.png' => __( 'qatar', 'multilingual-wp' ), 'reunion.png' => __( 'reunion', 'multilingual-wp' ), 'romania.png' => __( 'romania', 'multilingual-wp' ), 'russia.png' => __( 'russia', 'multilingual-wp' ), 'rwanda.png' => __( 'rwanda', 'multilingual-wp' ), 'saint-barthelemy.png' => __( 'saint barthelemy', 'multilingual-wp' ), 'saint-helena-dependencies.png' => __( 'saint helena dependencies', 'multilingual-wp' ), 'saint-helena.png' => __( 'saint helena', 'multilingual-wp' ), 'saint-kitts-and-nevis.png' => __( 'saint kitts and nevis', 'multilingual-wp' ), 'saint-lucia.png' => __( 'saint lucia', 'multilingual-wp' ), 'saint-martin.png' => __( 'saint martin', 'multilingual-wp' ), 'saint pierre and miquelon.png' => __( 'saint pierre and miquelon', 'multilingual-wp' ), 'saint vincent and the grenadines.png' => __( 'saint vincent and the grenadines', 'multilingual-wp' ), 'samoa.png' => __( 'samoa', 'multilingual-wp' ), 'san-marino.png' => __( 'san marino', 'multilingual-wp' ), 'sao-tome-and-principe.png' => __( 'sao tome and principe', 'multilingual-wp' ), 'saudi-arabia.png' => __( 'saudi arabia', 'multilingual-wp' ), 'scotland.png' => __( 'scotland', 'multilingual-wp' ), 'senegal.png' => __( 'senegal', 'multilingual-wp' ), 'serbia.png' => __( 'serbia', 'multilingual-wp' ), 'seychelles.png' => __( 'seychelles', 'multilingual-wp' ), 'sierra-leone.png' => __( 'sierra leone', 'multilingual-wp' ), 'singapore.png' => __( 'singapore', 'multilingual-wp' ), 'slovakia.png' => __( 'slovakia', 'multilingual-wp' ), 'slovenia.png' => __( 'slovenia', 'multilingual-wp' ), 'smom.png' => __( 'smom', 'multilingual-wp' ), 'solomon-islands.png' => __( 'solomon islands', 'multilingual-wp' ), 'somalia.png' => __( 'somalia', 'multilingual-wp' ), 'south-africa.png' => __( 'south africa', 'multilingual-wp' ), 'south-georgia.png' => __( 'south georgia', 'multilingual-wp' ), 'spain.png' => __( 'spain', 'multilingual-wp' ), 'spm.png' => __( 'spm', 'multilingual-wp' ), 'sri-lanka.png' => __( 'sri lanka', 'multilingual-wp' ), 'sudan.png' => __( 'sudan', 'multilingual-wp' ), 'suriname.png' => __( 'suriname', 'multilingual-wp' ), 'svalbard.png' => __( 'svalbard', 'multilingual-wp' ), 'svg.png' => __( 'svg', 'multilingual-wp' ), 'swaziland.png' => __( 'swaziland', 'multilingual-wp' ), 'sweden.png' => __( 'sweden', 'multilingual-wp' ), 'switzerland.png' => __( 'switzerland', 'multilingual-wp' ), 'syria.png' => __( 'syria', 'multilingual-wp' ), 'taiwan.png' => __( 'taiwan', 'multilingual-wp' ), 'tajikistan.png' => __( 'tajikistan', 'multilingual-wp' ), 'tanzania.png' => __( 'tanzania', 'multilingual-wp' ), 'thailand.png' => __( 'thailand', 'multilingual-wp' ), 'timor-leste.png' => __( 'timor leste', 'multilingual-wp' ), 'togo.png' => __( 'togo', 'multilingual-wp' ), 'tokelau.png' => __( 'tokelau', 'multilingual-wp' ), 'tonga.png' => __( 'tonga', 'multilingual-wp' ), 'trinidad-and-tobago.png' => __( 'trinidad and tobago', 'multilingual-wp' ), 'tunisia.png' => __( 'tunisia', 'multilingual-wp' ), 'turkey.png' => __( 'turkey', 'multilingual-wp' ), 'turkmenistan.png' => __( 'turkmenistan', 'multilingual-wp' ), 'turks-and-caicos-islands.png' => __( 'turks and caicos islands', 'multilingual-wp' ), 'tuvalu.png' => __( 'tuvalu', 'multilingual-wp' ), 'uganda.png' => __( 'uganda', 'multilingual-wp' ), 'ukraine.png' => __( 'ukraine', 'multilingual-wp' ), 'united-arab-emirates.png' => __( 'united arab emirates', 'multilingual-wp' ), 'united-kingdom.png' => __( 'united kingdom', 'multilingual-wp' ), 'united-states.png' => __( 'united states', 'multilingual-wp' ), 'uruguay.png' => __( 'uruguay', 'multilingual-wp' ), 'uzbekistan.png' => __( 'uzbekistan', 'multilingual-wp' ), 'vanuatu.png' => __( 'vanuatu', 'multilingual-wp' ), 'vatican-city.png' => __( 'vatican city', 'multilingual-wp' ), 'venezuela.png' => __( 'venezuela', 'multilingual-wp' ), 'vietnam.png' => __( 'vietnam', 'multilingual-wp' ), 'virgin-islands.png' => __( 'virgin islands', 'multilingual-wp' ), 'wales.png' => __( 'wales', 'multilingual-wp' ), 'wallis-and-futuna.png' => __( 'wallis and futuna', 'multilingual-wp' ), 'western-sahara.png' => __( 'western sahara', 'multilingual-wp' ), 'yemen.png' => __( 'yemen', 'multilingual-wp' ), 'zambia.png' => __( 'zambia', 'multilingual-wp' ), 'zimbabwe.png' => __( 'zimbabwe', 'multilingual-wp' ), ); \ No newline at end of file diff --git a/images/remove-language-icon.png b/images/remove-language-icon.png new file mode 100644 index 0000000..847a8ae Binary files /dev/null and b/images/remove-language-icon.png differ diff --git a/plugin.php b/plugin.php index bf3df09..973e146 100644 --- a/plugin.php +++ b/plugin.php @@ -6,10 +6,21 @@ Author: nikolov.tmw Author URI: http://themoonwatch.com Plugin URI: http://themoonwatch.com/multilingual-wp +*/ +/** + * This is the core file for the Multilingual WP plugin + * + * It contains the base Multilingual_WP class and calls all initialization + * functions. + * + * @package Multilingual WP + * @author Nikola Nikolov + * @copyright Copyleft (ɔ) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ - -Copyright (C) 2012-2013 Nikola Nikolov (nikolov.tmw@gmail.com) - +/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or @@ -35,84 +46,84 @@ class Multilingual_WP { * Holds a reference to the scb_MLWP_Options object, containing all of the plugin's settings * * @var scb_MLWP_Options object - **/ + */ public static $options; /** * Holds the URL to the plugin's directory * * @var string - **/ + */ public $plugin_url; /** * Holds the meta key name for the language posts associated with each original post * * @var string - **/ + */ public $languages_meta_key = '_mlwp_langs'; /** * Holds the meta key name that keeps the ID of the original post * * @var string - **/ + */ public $rel_p_meta_key = '_mlwp_rel_post'; /** * Holds the current link type mode * * @var string - **/ + */ public $lang_mode; /** * Holds the default language ID * * @var string - **/ + */ public $default_lang; /** * Holds the currently active language * * @var string - **/ + */ public $current_lang; /** * Holds the currently selected locale * * @var string - **/ + */ public $locale; /** * Holds a reference to the ID of the post we're currently interacting with * * @var string|Integer - **/ + */ public $ID; /** * Holds a reference to the post object with which we're currently interacting * * @var stdClass|WP_Post object - **/ + */ public $post; /** * Holds a reference to the post type of the post we're currently interacting with * * @var string - **/ + */ public $post_type; /** * Holds a reference to the ID's of all related languages for the post we're currently interacting with * * @var array - **/ + */ public $rel_langs; /** @@ -121,64 +132,57 @@ class Multilingual_WP { * Each key is a taxonomy name with all terms that the post is associated wih in that taxonomy. * * @var array - **/ + */ public $post_taxonomies; /** * Holds a reference to the ID of the term we're currently interacting with * * @var string|Integer - **/ + */ public $term_ID; /** * Holds a reference to the term object with which we're currently interacting * * @var stdClass|WP_Post object - **/ + */ public $term; /** * Holds a reference to the taxonomy of the term we're currently interacting with * * @var string - **/ + */ public $taxonomy; /** * Holds a reference to the ID's of all related languages for the term we're currently interacting with * * @var array - **/ + */ public $rel_t_langs; /** * Holds a reference to the ID's of all related languages for the parent of the term we're currently interacting with * * @var array - **/ + */ public $parent_rel_t_langs; /** * Holds a reference to the original post types names - each key is a hashed post type name * * @var array - **/ + */ public $hashed_post_types; /** * Holds a reference to the original taxonomy names - each key is a hashed taxonomy name * * @var array - **/ + */ public $hashed_taxonomies; - - /** - * Whether we're running on Windows or not - * - * @var boolean - **/ - public static $is_win = false; public $rel_posts; public $parent_rel_langs; @@ -188,10 +192,10 @@ class Multilingual_WP { private $t_slug_sfx = 'mlwp-sfx'; /** - * Caches various object's slugs(posts/pages/categories/etc.) - * - * @access private - **/ + * Caches various object's slugs(posts/pages/categories/etc.) + * + * @access private + */ private $slugs_cache = array( 'posts' => array(), 'categories' => array() ); /** @@ -200,35 +204,35 @@ class Multilingual_WP { * Holds the priority for filters that need to be applied last - therefore it should be a really high number * * @var Integer - **/ + */ public $late_fp = 10000; /** * Holds the query var, registered in the query vars array in WP_Query * * @var string - **/ + */ const QUERY_VAR = 'language'; /** * Referes to the pre-path mode for defining the language * * @var string - **/ + */ const LT_PRE = 'pre'; /** * Referes to the query argument mode for defining the language * * @var string - **/ + */ const LT_QUERY = 'qa'; /** * Referes to the subdomain mode for defining the language * * @var string - **/ + */ const LT_SD = 'sd'; private $_doing_save = false; @@ -247,7 +251,7 @@ class Multilingual_WP { * * @access private * @var array - **/ + */ private $builtin_rules = array(); public static function plugin_init() { @@ -329,17 +333,10 @@ public static function plugin_init() { } global $Multilingual_WP; - $class_name = apply_filters( 'mlwp_class_name', 'Multilingual_WP' ); - $Multilingual_WP = new $class_name(); + $Multilingual_WP = new Multilingual_WP(); // Include required files self::include_additional_files(); - - self::$is_win = strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN'; - - if ( self::$is_win ) { - include_once( dirname( __FILE__ ) . '/win_locales.php' ); - } } function __construct() { @@ -355,8 +352,6 @@ function __construct() { add_action( 'plugins_loaded', array( $this, 'setup_locale' ), $this->late_fp ); add_filter( 'locale', array( $this, 'set_locale' ), $this->late_fp ); - - self::$is_win = strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN'; } public static function include_additional_files() { @@ -471,10 +466,10 @@ public function fix_htaccess_rewrite_rules( $rules ) { } /** - * Registers any filter hooks that the plugin is using - * @access private - * @uses add_filter() - **/ + * Registers any filter hooks that the plugin is using + * @access private + * @uses add_filter() + */ private function add_filters() { add_filter( 'wp_unique_post_slug', array( $this, 'fix_post_slug' ), $this->late_fp, 6 ); @@ -555,10 +550,10 @@ private function add_filters() { } /** - * Registers any action hooks that the plugin is using - * @access private - * @uses add_action() - **/ + * Registers any action hooks that the plugin is using + * @access private + * @uses add_action() + */ private function add_actions() { add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); @@ -628,9 +623,9 @@ private function add_actions() { } /** - * Registers a custom meta box for the Comment Language - * @access public - **/ + * Registers a custom meta box for the Comment Language + * @access public + */ public function admin_init() { add_meta_box( 'MLWP_Comments', __( 'Comment Language', 'multilingual-wp' ), array( $this, 'comment_language_metabox' ), 'comment', 'normal' ); } @@ -644,13 +639,13 @@ public function add_gsmg_support() { } /** - * Attempts to automatically download .mo files for all enabled languages - * - * @access public - * - * @param boolean $force Whether to force the update or wait until two weeks since the last update have passed - * @param boolean|string $for_lang Whether to only attempt a download for a specific language - **/ + * Attempts to automatically download .mo files for all enabled languages + * + * @access public + * + * @param boolean $force Whether to force the update or wait until two weeks since the last update have passed + * @param boolean|string $for_lang Whether to only attempt a download for a specific language + */ public function update_gettext( $force = false, $for_lang = false ) { if ( ! is_dir( WP_LANG_DIR ) ) { if ( ! @mkdir( WP_LANG_DIR ) ) @@ -780,8 +775,8 @@ public function add_toolbar_langs( $admin_bar ) { } /** - * Registers all of the plugin's shortcodes - **/ + * Registers all of the plugin's shortcodes + */ private function register_shortcodes() { $this->add_shortcode( 'mlwp', array( $this, 'mlwp_translation_shortcode' ) ); @@ -865,7 +860,7 @@ public function get_orig_title( $title, $id = false ) { * @uses apply_filters() calls "mlwp_gettext" * * @return string - The [maybe]translated string - **/ + */ public function __( $text ) { $text = $this->parse_quicktags( $text ); $text = $this->parse_transl_shortcodes( $text ); @@ -881,7 +876,7 @@ public function __( $text ) { * @uses Multilingual_WP::__() * * @return Null - **/ + */ public function _e( $text ) { echo $this->__( $text ); } @@ -955,7 +950,7 @@ public function parse_transl_shortcodes( $content ) { * * @access public * @param string $text The text for which to retrieve translations - **/ + */ public function get_translations( $text ) { $this->record_translations = true; $this->recorded_translations = array(); @@ -974,7 +969,7 @@ public function get_translations( $text ) { * and the value is the text for that language. * @param string $output (Optional) The desired output - defaults to "shortcode" - returning translations wrapped in * the corresponding shortcode. Can also be "quicktags" to return translations wrapped in quicktags( like "[:{$lang}]{$text}" ) - **/ + */ public function join_translations( $translations, $output = 'shortcode' ) { if ( ! is_array( $translations ) ) { return $translations; @@ -1538,7 +1533,7 @@ public function set_locale_from_query( $wp ) { * * @access public * @param WP $wp - **/ + */ public function set_pt_from_query( $wp ) { // Set the post type except when on search results page, since we've already set the correct post types if ( isset( $wp->query_vars[ self::QUERY_VAR ] ) && $this->is_enabled( $wp->query_vars[ self::QUERY_VAR ] ) && $wp->query_vars[ self::QUERY_VAR ] != $this->default_lang && ( ! isset( $wp->query_vars['s'] ) || ! $wp->query_vars['s'] ) ) { @@ -1608,7 +1603,7 @@ public function fix_home_page( $wp ) { * @access public * * @return Null - **/ + */ public function fix_queried_object() { global $wp_query, $wp; @@ -1649,7 +1644,7 @@ public function override_suppress_filters( $query ) { * * @access public * @param WP_Query $query - **/ + */ public function maybe_unset_queried_obj( $query ) { if ( isset( $query->query['pagename'] ) && isset( $query->query['post_type'] ) && isset( $query->query['post_type'] ) && $this->is_gen_pt( $query->query['post_type'] ) && isset( $query->queried_object ) ) { unset( $query->queried_object, $query->queried_object_id ); @@ -1661,7 +1656,7 @@ public function maybe_unset_queried_obj( $query ) { * * @access public * @param WP_Query $query - **/ + */ public function fix_page_for_posts( $query ) { if ( $query->is_posts_page && isset( $query->query['pagename'] ) && isset( $query->query['post_type'] ) && $this->is_gen_pt( $query->query['post_type'] ) && $this->unhash_pt_name( $query->query['post_type'] ) == 'page' ) { $post_type = $query->query['post_type']; @@ -1674,7 +1669,7 @@ public function fix_page_for_posts( $query ) { * * @access public * @param WP $wp - **/ + */ public function fix_search_query( $wp ) { if ( isset( $wp->query_vars['s'] ) ) { $_post_types = array(); @@ -1714,7 +1709,7 @@ public function fix_search_query( $wp ) { * * @access public * @param WP $wp - **/ + */ public function fix_hierarchical_requests( $wp ) { if ( isset( $wp->query_vars['post_type'] ) && $this->is_gen_pt( $wp->query_vars['post_type'] ) ) { $slug = preg_replace( '~.*?name=(.*?)&.*~', '$1', str_replace( '%2F', '/', $wp->matched_query ) ); @@ -1728,7 +1723,7 @@ public function fix_hierarchical_requests( $wp ) { * * @access public * @param WP $wp - **/ + */ public function fix_no_pt_request( $wp ) { if ( isset( $wp->query_vars[ self::QUERY_VAR ] ) && isset( $wp->query_vars['name'] ) && ! isset( $wp->query_vars['post_type'] ) && $this->is_enabled( $wp->query_vars[ self::QUERY_VAR ] ) ) { $lang = $wp->query_vars[ self::QUERY_VAR ]; @@ -1765,9 +1760,9 @@ public function na_message( $lang = false, $def_message = '' ) { } /** - * Redirects to the proper URL in case the requested URL is one that has "mlwp_..." - * - **/ + * Redirects to the proper URL in case the requested URL is one that has "mlwp_..." + * + */ public function canonical_redirect() { global $wp; @@ -2448,7 +2443,8 @@ public function update_rel_langs( $post = false ) { if ( isset( $_POST[ "content_{$lang}" ] ) ) { $_post['post_content'] = $_POST[ "content_{$lang}" ]; } else { - $_post['post_content'] = ''; + // The current content will be preserved + // $_post['post_content'] = ''; } if ( isset( $_POST[ "title_{$lang}" ] ) ) { $_post['post_title'] = $_POST[ "title_{$lang}" ]; @@ -2557,9 +2553,8 @@ public function update_rel_t_langs( $term = false ) { // Add a special suffix for default languages if ( $lang == $this->default_lang && stripos( $_term['slug'], $this->t_slug_sfx ) === false ) { $_term['slug'] = $_term['slug'] . $this->t_slug_sfx; - } - // Remove the suffix if this is no-longer the default language - if ( $lang != $this->default_lang && stripos( $_term['slug'], $this->t_slug_sfx ) !== false ) { + } elseif ( $lang != $this->default_lang && stripos( $_term['slug'], $this->t_slug_sfx ) !== false ) { + // Remove the suffix if this is no-longer the default language $_term['slug'] = str_ireplace( $this->t_slug_sfx, '', $_term['slug'] ); } @@ -2570,6 +2565,17 @@ public function update_rel_t_langs( $term = false ) { $this->update_term_slug_c( $_term ); } + // If this is the default language - copy over the title/content/etc over + if ( $lang == $this->default_lang ) { + $_term = (array) $_term; + $term = (array) $this->term; + $term['name'] = $_term['name']; + $term['description'] = $_term['description']; + $term['slug'] = str_ireplace( $this->t_slug_sfx, '', $_term['slug'] ); + + $this->insert_term( $term['name'], $this->taxonomy, $term ); + } + unset( $_term ); } } @@ -2577,7 +2583,6 @@ public function update_rel_t_langs( $term = false ) { if ( $term && $old_id ) { $this->setup_term_vars( $old_id ); } - // exit; } private function register_post_types() { @@ -2592,7 +2597,7 @@ private function register_post_types() { return false; } - $post_types = get_post_types( array( ), 'objects' ); + $post_types = get_post_types( array(), 'objects' ); $languages = self::$options->languages; $show_ui = (bool) self::$options->show_ui; @@ -2828,12 +2833,8 @@ public function admin_scripts( $hook ) { } /** - * Creates any missing related posts - * - * - * - * - **/ + * Creates any missing related posts + */ public function create_rel_posts( $post = false ) { if ( $post ) { $this->setup_post_vars( $post->ID ); @@ -2899,12 +2900,8 @@ public function create_rel_posts( $post = false ) { } /** - * Creates any missing related posts - * - * - * - * - **/ + * Creates any missing related terms + */ public function create_rel_terms( $term = false, $taxonomy = false, $pop_rel_terms = true ) { if ( $term && $taxonomy ) { $_term = is_object( $term ) ? $term->term_id : $term; @@ -2931,12 +2928,12 @@ public function create_rel_terms( $term = false, $taxonomy = false, $pop_rel_ter } } - // If the creation queue is not empty, loop through all languages and create corresponding posts + // If the creation queue is not empty, loop through all languages and create corresponding terms if ( ! empty( $to_create ) ) { foreach ( $to_create as $lang ) { $_taxonomy = $this->hash_tax_name( $this->taxonomy, $lang ); $parent = 0; - // Look-up for a parent post + // Look-up for a parent term if ( $this->parent_rel_t_langs && isset( $this->parent_rel_t_langs[ $lang ] ) ) { $parent = $this->parent_rel_t_langs[ $lang ]; } @@ -3291,19 +3288,19 @@ public function convert_term_URL( $url, $term = false, $taxonomy = false ) { } /** - * Gets the default and language-specific permalink slug for a taxonomy - * - * First checks for the built-in taxonomies and the options for changing their slug(from Permalinks section) - * If it's not a built-in taxonomy, we get the taxonomy object and check if a slug is set in it's rewrite settings - * The outcome of the above is the default slug for that taxonomy - * Then we check the plugin's settings to see if the user has entered a custom slug for that taxonomy - * Finally we return an array with two elements - first one is default and second one is the language-specific one - * - * @access public - * @param string $tax Name of taxonomy for which to obtain a language-specific slug. - * @param string $lang Optional. The language to obtain the slug for. Defaults to current language - * @return array First element is the default slug, second is the language-specific one. - **/ + * Gets the default and language-specific permalink slug for a taxonomy + * + * First checks for the built-in taxonomies and the options for changing their slug(from Permalinks section) + * If it's not a built-in taxonomy, we get the taxonomy object and check if a slug is set in it's rewrite settings + * The outcome of the above is the default slug for that taxonomy + * Then we check the plugin's settings to see if the user has entered a custom slug for that taxonomy + * Finally we return an array with two elements - first one is default and second one is the language-specific one + * + * @access public + * @param string $tax Name of taxonomy for which to obtain a language-specific slug. + * @param string $lang Optional. The language to obtain the slug for. Defaults to current language + * @return array First element is the default slug, second is the language-specific one. + */ public function get_taxonomy_slug( $tax, $lang = false ) { // "{default_language}/" is prepended to the "category_base" and "tag_base" options - so we have to remove that for categories and tags if ( $tax == 'category' ) { @@ -3333,15 +3330,15 @@ public function get_taxonomy_slug( $tax, $lang = false ) { } /** - * Gets rid of the trailing slash for singular posts - * - * If we're using the query argument mode, we want to make sure that single posts don't have the trailing slash at the end. - * - * @access public - * @param string $url The url with or without a trailing slash. - * @param string $type The type of URL being considered (e.g. single, category, etc). - * @return string - **/ + * Gets rid of the trailing slash for singular posts + * + * If we're using the query argument mode, we want to make sure that single posts don't have the trailing slash at the end. + * + * @access public + * @param string $url The url with or without a trailing slash. + * @param string $type The type of URL being considered (e.g. single, category, etc). + * @return string + */ public function remove_single_post_trailingslash( $url, $type = '' ) { if ( ( $type == 'single' || $type == 'page' ) && self::$options->def_lang_in_url ) { $url = untrailingslashit( $url ); @@ -3350,41 +3347,50 @@ public function remove_single_post_trailingslash( $url, $type = '' ) { } /** - * Generates a language switcher - * - * @access public - * - * @param array|string $options - If array - one or more of the following options. If string the type - * of the swticher(see $type bellow for options) - * - * Available options in the $options Array: - * @param string $type The type of the switcher. One of the following: 'text'(language labels only), - * 'image'(language flags only), 'both'(labels and flags), 'select'|'dropdown'(use labels to create a - * drop-down with redirection on language select). Default: 'image' + * @param string $wrap The wrapping HTML element for each language. + * Examples: 'li', 'span', 'div', 'p'... Default: 'li' + * @param string $outer_wrap The wrapping HTML element for each language. + * Examples: 'ul', 'ol', 'div'... Default: 'ul' + * @param string $class The value for the HTML 'class' attribute for the + * $outer_wrap element. Default: 'mlwp-lang-switcher' + * @param string $id The value for the HTML 'id' attribute for the + * $outer_wrap element. Default: "mlwp_lang_switcher_X", + * where "X" is an incrementing number starting from + * 1(it increments any time this function is called without passing 'id' option) + * @param string $active_class The value for the HTML 'class' attribute + * for the currently active language's element. Default: 'active' + * @param boolean|string $return Whether to return or echo the output. + * Pass false for echo. Pass 'html' to get the ready html. Pass + * 'array' to retrieve a multidimensional array with the following structure: + * array( + * 'xx' => array( + * 'label' => 'Language label', + * 'image' => 'URL to the flag image of this language', + * 'active' => true|false, // Is this the active language + * 'url' => 'Proper(fixed) URL for this language', + * 'default' => true|false, // Is this the default language + * ) + * ) + * That's useful for when trying to build a highly customized switcher. Default: false + * @param boolean $hide_current Whether to display or not the currently active language + * @param string|integer $flag_size The size for the flag image. + * One of: 16, 24, 32, 48, 64. Default: gets user's preference(plugin option) + * + * @uses apply_filters() Calls "mlwp_lang_switcher_pre" passing the user options and the defaults. If output is provided, returns that + * + */ public function build_lang_switcher( $options = array() ) { static $switcher_counter; $options = is_array( $options ) ? $options : array( 'type' => $options ); @@ -3500,17 +3506,21 @@ public function build_lang_switcher( $options = array() ) { } /** - * Gets the flag image for a specified/default language - * - * @access public - * - * @uses apply_filters() calls "mlwp_get_flag", passing the found flag, language and size as additional parameters. Return something different than false to override this function - * - * @param string $language The language for which to retreive the flag. Optional, defaults to current - * @param integer $size The size at which to get the flag. Optional, defaults to plugin settings - * - * @return string - the URL for the flag, or a general "earth.png" flag if none was found - **/ + * Gets the flag image for a specified/default language + * + * @access public + * + * @param string $language The language for which to retreive + * the flag. Optional, defaults to current + * @param integer $size The size at which to get the flag. + * Optional, defaults to plugin settings + * + * @uses apply_filters() calls "mlwp_get_flag", passing + * the found flag, language and size as additional parameters. + * Return something different than false to override this function + * + * @return string - the URL for the flag, or a general "earth.png" flag if none was found + */ public function get_flag( $language = '', $size = '' ) { $language = $language && isset( self::$options->languages[ $language ] ) ? $language : $this->current_lang; $size = $size && in_array( intval( $size ), array( 16, 24, 32, 48, 64 ) ) ? $size : self::$options->dfs; @@ -3558,11 +3568,13 @@ public function curPageURL() { } /** - * Gets the slug of an object - uses own cache - * - * @param integer $id The ID of the object that the slug is requested - * @param string $type The type of the object in question. "post"(any general post type), "category"(any terms) or mlwp_post(plugin-created post types) - **/ + * Gets the slug of an object - uses own cache + * + * @param integer $id The ID of the object that the slug is requested + * @param string $type The type of the object in question. + * "post"(any general post type), "category"(any terms) or + * mlwp_post(plugin-created post types) + */ public function get_obj_slug( $id, $type, $taxonomy = false ) { $_id = "_{$id}"; if ( $type == 'post' ) { @@ -3624,9 +3636,9 @@ public function add_slug_cache( $id, $slug, $type ) { } /** - * Createс a custom meta box for the Comment Language - * @access public - **/ + * Createс a custom meta box for the Comment Language + * @access public + */ public function comment_language_metabox( $comment ) { $curr_lang = get_comment_meta( $comment->comment_ID, '_comment_language', true ); ?> @@ -3671,9 +3683,9 @@ public function get_mlwp_comment_query() { } /** - * Adds a "Language" header for the Edit Comments screen - * @access public - **/ + * Adds a "Language" header for the Edit Comments screen + * @access public + */ public function filter_edit_comments_t_headers( $columns ) { if ( ! empty($columns) ) { $response = $columns['response']; @@ -3686,9 +3698,9 @@ public function filter_edit_comments_t_headers( $columns ) { } /** - * Renders the language for each comment in the Edit Comments screen - * @access public - **/ + * Renders the language for each comment in the Edit Comments screen + * @access public + */ public function render_comment_lang_col( $column, $commentID ) { if ( $column == 'comm_language' ) { $comm_lang = get_comment_meta( $commentID, '_comment_language', true ); @@ -3701,9 +3713,9 @@ public function render_comment_lang_col( $column, $commentID ) { } /** - * Handles the AJAX POST for bulk updating of comments language - * @access public - **/ + * Handles the AJAX POST for bulk updating of comments language + * @access public + */ public function handle_ajax_update() { if ( isset( $_POST['language'] ) && isset( $_POST['ids'] ) && is_array( $_POST['ids'] ) && check_admin_referer( 'bulk-comments' ) ) { @@ -3729,9 +3741,9 @@ public function handle_ajax_update() { } /** - * Prints the necessary JS for the Edit Comments screen - * @access public - **/ + * Prints the necessary JS for the Edit Comments screen + * @access public + */ public function print_comment_scripts() { $languages = array(); foreach ( self::$options->enabled_langs as $lang ) { @@ -3826,9 +3838,9 @@ function set_language () { } /** - * Saves the comment language(single-comment-editting only) - * @access public - **/ + * Saves the comment language(single-comment-editting only) + * @access public + */ public function save_comment_lang( $commentID ) { if ( isset( $_POST['mlwpc_language'] ) && $this->is_enabled( $_POST['mlwpc_language'] ) ) { update_comment_meta( $commentID, '_comment_language', $_POST['mlwpc_language'] ); @@ -3836,10 +3848,10 @@ public function save_comment_lang( $commentID ) { } /** - * Sets the language for new comments - * - * @access public - **/ + * Sets the language for new comments + * + * @access public + */ public function new_comment( $commentID ) { $comm_lang = isset( $_POST['mlwpc_comment_lang'] ) && $this->is_enabled( $_POST['mlwpc_comment_lang'] ) ? $_POST['mlwpc_comment_lang'] : $this->default_lang; @@ -3852,23 +3864,27 @@ public function new_comment( $commentID ) { } /** - * Renders a hidden input in the comments form - * - * This hidden input contains the permalink of the current post(without the hostname) and is used to properly assign the language of the comment as well as the back URL - * - * @access public - **/ + * Renders a hidden input in the comments form + * + * This hidden input contains the permalink of the current + * post(without the hostname) and is used to properly assign + * the language of the comment as well as the back URL + * + * @access public + */ public function comment_form_hook( $post_id ) { echo ''; } /** - * Filters comments for the current language only - * - * This function is called whenever comments are fetched for the comments_template() function. This way the right comments(according to the current language) are fetched automatically. - * - * @access public - **/ + * Filters comments for the current language only + * + * This function is called whenever comments are fetched + * for the comments_template() function. This way the right + * comments(according to the current language) are fetched automatically. + * + * @access public + */ public function filter_comments_by_lang( $comments, $post_id ) { global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; @@ -3925,5 +3941,5 @@ public function urlencode_regex_cb( $matches ) { } } -// Let's allow anyone to override our class definition - this way anyone can extend the plugin and add/overwrite functionality without having the need to modify the plugin files -scb_MLWP_init( array( apply_filters( 'mlwp_class_name', 'Multilingual_WP' ), 'plugin_init' ) ); + +scb_MLWP_init( array( 'Multilingual_WP', 'plugin_init' ) ); diff --git a/readme.txt b/readme.txt index ce51066..3586fc7 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: multilingual, translations, content Requires at least: 3.5 Tested up to: 3.5.1 -Stable tag: trunk +Stable tag: 0.1 This plugins allows you to easily integrate multiple language support in your WordPress site. @@ -14,9 +14,8 @@ This plugins allows you to easily integrate multiple language support in your Wo From the 25.04.2013 commit, custom post type names have changed drastically. If you've used an older version and you still want to keep all of your translation posts, follow this guide here - https://github.com/nikolov-tmw/multilingual-wp/wiki/Migrating-from-non-hashed-to-hashed-CPT-names === WARNING: === -This plugin is still in development! It's only tested in a development environment and with every release things could get fixed or break. Use it in production environments on your own risk! +This plugin is still in development! It's been tested in production environments for relatively small websites and it's been working good so far. This plugin adds translations by creating a new post for every language that you have enabled. So if you have 10 posts and 3 enabled languages, you'll end-up(in your database) with 30 posts. While this seems fine for smaller websites/blogs, I can't guarantee that it will behave properly in larger scale installs. If you have thousands of posts that you want to translate, then this might NOT be the plugin you're looking for. -I haven't tested the plugin in an environment with a lot of posts so far, but if someone wants to do that for me - that'd be great :) I'll eventually test that when I'm closer to releasing the plugin. == Installation == @@ -24,4 +23,5 @@ Click on the ZIP button above and then extract it to your plugins directory(or e == Changelog == -Changelog will come later... \ No newline at end of file += 0.1 = + * Initial stable release - almost all of the main features are in place with only a couple of them still missing \ No newline at end of file diff --git a/remove-language-page.php b/remove-language-page.php index 0eb55a0..4cb31da 100644 --- a/remove-language-page.php +++ b/remove-language-page.php @@ -1,4 +1,13 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class Multilingual_WP_Remove_Language_Page extends scb_MLWP_AdminPage { protected $admin_notice = false; @@ -10,6 +19,7 @@ public function setup() { 'page_title' => __( 'Remove a Language', 'multilingual-wp' ), 'parent' => 'multilingual-wp', 'action_link' => false, + 'screen_icon' => 'mlwp_remove_language' ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10 ); diff --git a/scb/AdminPage.php b/scb/AdminPage.php index 1952007..525ab9c 100644 --- a/scb/AdminPage.php +++ b/scb/AdminPage.php @@ -1,6 +1,19 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ abstract class scb_MLWP_AdminPage { /** Page args diff --git a/scb/Forms.php b/scb/Forms.php index 497ac1d..a5d6462 100644 --- a/scb/Forms.php +++ b/scb/Forms.php @@ -1,6 +1,19 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class scb_MLWP_Forms { diff --git a/scb/Options.php b/scb/Options.php index 517d07f..d695abf 100644 --- a/scb/Options.php +++ b/scb/Options.php @@ -1,6 +1,19 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class scb_MLWP_Options { diff --git a/scb/Util.php b/scb/Util.php index 48af4c9..9620243 100644 --- a/scb/Util.php +++ b/scb/Util.php @@ -1,6 +1,19 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class scb_MLWP_Util { diff --git a/scb/Widget.php b/scb/Widget.php index 9ea1233..a4cae73 100644 --- a/scb/Widget.php +++ b/scb/Widget.php @@ -1,6 +1,19 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ abstract class scb_MLWP_Widget extends WP_Widget { protected $defaults = array(); diff --git a/scb/load.php b/scb/load.php index db79ce4..e1d159b 100644 --- a/scb/load.php +++ b/scb/load.php @@ -1,11 +1,26 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ $GLOBALS['_scb_MLWP_data'] = array( 57, __FILE__, array( 'scb_MLWP_Util', 'scb_MLWP_Options', 'scb_MLWP_Forms', 'scb_MLWP_Widget', 'scb_MLWP_AdminPage', ) ); -if ( !class_exists( 'scb_MLWP_Load4' ) ) : +if ( ! class_exists( 'scb_MLWP_Load4' ) ) : /** * The main idea behind this class is to load the most recent version of the scb_MLWP_ classes available. * diff --git a/settings-page.php b/settings-page.php index c2e6559..79861d1 100644 --- a/settings-page.php +++ b/settings-page.php @@ -1,4 +1,13 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ class Multilingual_WP_Settings_Page extends scb_MLWP_AdminPage { protected $admin_notice = false; diff --git a/template-tags.php b/template-tags.php index 562265d..b795abf 100644 --- a/template-tags.php +++ b/template-tags.php @@ -1,19 +1,28 @@ + * @copyright Copyleft (ɔ) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ /** -* Gives access to the plugin instance -* -* @global Multilingual_WP $GLOBALS['Multilingual_WP'] -**/ + * Gives access to the plugin instance + * + * @global Multilingual_WP $GLOBALS['Multilingual_WP'] + */ function &_mlwp() { return $GLOBALS['Multilingual_WP']; } /** -* Renders a language switcher -* -* @uses Multilingual_WP::build_lang_switcher() -**/ + * Renders a language switcher + * + * @uses Multilingual_WP::build_lang_switcher() + */ function mlwp_lang_switcher( $options = array() ) { return _mlwp()->build_lang_switcher( $options ); } diff --git a/update-posts-page.php b/update-posts-page.php index abe11c0..4b04084 100644 --- a/update-posts-page.php +++ b/update-posts-page.php @@ -1,4 +1,22 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + * + * @todo Add support for migrating from other multilingual plugins + */ class Multilingual_WP_Update_Posts_Page extends scb_MLWP_AdminPage { protected $admin_notice = false; @@ -57,7 +75,8 @@ public function form_handler() { } global $Multilingual_WP, $qtranslate_slug; - $default_lang = $Multilingual_WP->get_options()->default_lang; + $default_lang = $Multilingual_WP->default_lang; + $languages = $Multilingual_WP->get_options( 'enabled_langs' ); if ( $_POST['update_type'] == 'terms' ) { $tpp = isset( $_POST['terms_per_batch'] ) && intval( $_POST['terms_per_batch'] ) ? intval( $_POST['terms_per_batch'] ) : 20; @@ -73,13 +92,15 @@ public function form_handler() { foreach ( $terms as $term ) { if ( $term->parent && ! isset( $updated_terms[ $term->parent ] ) ) { - $_parent = get_term( intval( $term->parent ), $term->taxonomy ); + $_parent = $Multilingual_WP->get_term( intval( $term->parent ), $term->taxonomy ); $message[] = '

' . sprintf( __( 'The term "%1$s" was ignored, because it\'s parent term "%2$s" has not been updated yet.', 'multilingual-wp' ), $term->name, $_parent->name ) . '

'; continue; } @set_time_limit( 30 * $langs_count ); $Multilingual_WP->setup_term_vars( $term->term_id, $term->taxonomy ); + $rel_langs = $Multilingual_WP->rel_t_langs; + $Multilingual_WP->create_rel_terms(); // Move over from qTranslate @@ -88,22 +109,41 @@ public function form_handler() { $title = isset( $qtrans_term_names[ $term->name ] ) ? $qtrans_term_names[ $term->name ] : array(); foreach ( $title as $lang => $tit ) { if ( $Multilingual_WP->is_enabled( $lang ) ) { - if ( $lang == $default_lang ) { - $term->description = isset( $contents[ $lang ] ) ? $contents[ $lang ] : $term->description; - $term->name = $tit; + if ( isset( $rel_langs[ $lang ] ) && ( $_term = $Multilingual_WP->get_term( $rel_langs[ $lang ], $Multilingual_WP->hash_tax_name( $term->taxonomy, $lang ) ) ) ) { + $_POST[ "description_{$lang}" ] = $_term->description; + $_POST[ "name_{$lang}" ] = $_term->name; + $_POST[ "slug_{$lang}" ] = $_term->slug; } else { - $_POST[ "description_{$lang}" ] = isset( $contents[ $lang ] ) ? $contents[ $lang ] : ''; - $_POST[ "name_{$lang}" ] = $tit; - - // Import slug for this language from the qTranslate Slug plugin - if ( $qtslug ) { - $_POST[ "slug_{$lang}" ] = get_term_meta( $term->term_id, $qtranslate_slug->get_meta_key( $lang ), true ); + if ( $lang == $default_lang ) { + $term->description = isset( $contents[ $lang ] ) ? $contents[ $lang ] : $term->description; + $term->name = $tit; + } else { + $_POST[ "description_{$lang}" ] = isset( $contents[ $lang ] ) ? $contents[ $lang ] : ''; + $_POST[ "name_{$lang}" ] = $tit; + + // Import slug for this language from the qTranslate Slug plugin + if ( $qtslug ) { + $_POST[ "slug_{$lang}" ] = get_term_meta( $term->term_id, $qtranslate_slug->get_meta_key( $lang ), true ); + } } } } } } elseif ( false ) { // TODO: Add support for other multilanguage plugins + } else { + // Set default language details + if ( isset( $rel_langs[ $default_lang ] ) && ( $_term = $Multilingual_WP->get_term( $rel_langs[ $default_lang ], $Multilingual_WP->hash_tax_name( $term->taxonomy, $lang ) ) ) ) { + // If translation already exists, assign that content + // This way we won't override default languages + $_POST[ "description_{$default_lang}" ] = $term->description = $_term->description; + $_POST[ "name_{$default_lang}" ] = $term->name = $_term->name; + $_POST[ "slug_{$default_lang}" ] = $term->slug = $_term->slug; + } else { + $_POST[ "description_{$default_lang}" ] = $term->description; + $_POST[ "name_{$default_lang}" ] = $term->name; + $_POST[ "slug_{$default_lang}" ] = $term->slug; + } } // Update the default language post @@ -139,7 +179,7 @@ public function form_handler() { $message = array(); - $qtslug = class_exists( 'QtranslateSlug' ) && $qtranslate_slug; + $qtslug = class_exists( 'QtranslateSlug' ) && $qtranslate_slug && method_exists( $qtranslate_slug, 'get_meta_key' ); $langs_count = count( $this->options->enabled_langs ); foreach ( $posts as $post ) { @@ -150,6 +190,8 @@ public function form_handler() { @set_time_limit( 30 * $langs_count ); $Multilingual_WP->setup_post_vars( $post->ID ); + $rel_langs = $Multilingual_WP->rel_langs; + $Multilingual_WP->create_rel_posts(); // Move over from qTranslate @@ -158,17 +200,24 @@ public function form_handler() { $titles = qtrans_split( $post->post_title ); foreach ( $titles as $lang => $title ) { if ( $Multilingual_WP->is_enabled( $lang ) ) { - if ( $lang == $default_lang ) { - $_POST[ "content_{$lang}" ] = $post->post_content = isset( $contents[ $lang ] ) ? $contents[ $lang ] : $post->post_content; - $_POST[ "title_{$lang}" ] = $post->post_title = $title; - $_POST[ "post_name_{$lang}" ] = $post->post_name; + // We've already imported this translation, so add the current data + if ( isset( $rel_langs[ $lang ] ) && ( $_post = get_post( $rel_langs[ $lang ] ) ) ) { + $_POST[ "content_{$lang}" ] = $_post->post_content; + $_POST[ "title_{$lang}" ] = $_post->post_title; + $_POST[ "post_name_{$lang}" ] = $_post->post_name; } else { - $_POST[ "content_{$lang}" ] = isset( $contents[ $lang ] ) ? $contents[ $lang ] : $post->post_content; - $_POST[ "title_{$lang}" ] = $title; - - // Import slug for this language from the qTranslate Slug plugin - if ( $qtslug ) { - $_POST[ "post_name_{$lang}" ] = get_post_meta( $post->ID, $qtranslate_slug->get_meta_key( $lang ), true ); + if ( $lang == $default_lang ) { + $_POST[ "content_{$lang}" ] = $post->post_content = isset( $contents[ $lang ] ) ? $contents[ $lang ] : $post->post_content; + $_POST[ "title_{$lang}" ] = $post->post_title = $title; + $_POST[ "post_name_{$lang}" ] = $post->post_name; + } else { + $_POST[ "content_{$lang}" ] = isset( $contents[ $lang ] ) ? $contents[ $lang ] : $post->post_content; + $_POST[ "title_{$lang}" ] = $title; + + // Import slug for this language from the qTranslate Slug plugin + if ( $qtslug ) { + $_POST[ "post_name_{$lang}" ] = get_post_meta( $post->ID, $qtranslate_slug->get_meta_key( $lang ), true ); + } } } } @@ -177,9 +226,17 @@ public function form_handler() { // TODO: Add support for other multilanguage plugins } else { // Set default language details, otherwise post content gets set to empty string - $_POST[ "content_{$default_lang}" ] = $post->post_content; - $_POST[ "title_{$default_lang}" ] = $post->post_title; - $_POST[ "post_name_{$default_lang}" ] = $post->post_name; + if ( isset( $rel_langs[ $default_lang ] ) && ( $_post = get_post( $rel_langs[ $default_lang ] ) ) ) { + // If translation already exists, assign that content + // This way we won't override default languages + $_POST[ "content_{$default_lang}" ] = $post->post_content = $_post->post_content; + $_POST[ "title_{$default_lang}" ] = $post->post_title = $_post->post_title; + $_POST[ "post_name_{$default_lang}" ] = $post->post_name = $_post->post_name; + } else { + $_POST[ "content_{$default_lang}" ] = $post->post_content; + $_POST[ "title_{$default_lang}" ] = $post->post_title; + $_POST[ "post_name_{$default_lang}" ] = $post->post_name; + } } // Update the default language post diff --git a/widgets.php b/widgets.php index e127932..d4b2679 100644 --- a/widgets.php +++ b/widgets.php @@ -1,11 +1,20 @@ + * @copyright Copyleft (?) 2012-2013, Nikola Nikolov + * @license {@link http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3} + * @since 0.1 + */ /** -* Language Switcher Widget -* -* @access public -* @uses mlwp_lang_switcher() -*/ + * Language Switcher Widget + * + * @access public + * @uses mlwp_lang_switcher() + */ class MLWP_Lang_Switcher_Widget extends scb_MLWP_Widget { protected $defaults = array( 'title' => '', diff --git a/win_locales.php b/win_locales.php deleted file mode 100644 index 6b16d76..0000000 --- a/win_locales.php +++ /dev/null @@ -1,45 +0,0 @@ -win_locales = array( - 'chinese' => __( 'Chinese', 'multilingual-wp' ), - 'chinese-simplified' => __( 'Chinese (simplified)', 'multilingual-wp' ), - 'chinese-traditional' => __( 'Chinese (traditional)', 'multilingual-wp' ), - 'csy' => __( 'Czech', 'multilingual-wp' ), - 'dan' => __( 'Danish', 'multilingual-wp' ), - 'dutch' => __( 'Dutch (default)', 'multilingual-wp' ), - 'belgian' => __( 'Dutch (Belgium)', 'multilingual-wp' ), - 'english' => __( 'English', 'multilingual-wp' ), - 'australian' => __( 'English (Australia)', 'multilingual-wp' ), - 'canadian' => __( 'English (Canada)', 'multilingual-wp' ), - 'english-nz' => __( 'English (New Zealand)', 'multilingual-wp' ), - 'eng' => __( 'English (United Kingdom)', 'multilingual-wp' ), - 'american' => __( 'English (United States)', 'multilingual-wp' ), - 'fin' => __( 'Finnish', 'multilingual-wp' ), - 'fra' => __( 'French (default)', 'multilingual-wp' ), - 'frb' => __( 'French (Belgium)', 'multilingual-wp' ), - 'frc' => __( 'French (Canada)', 'multilingual-wp' ), - 'french-swiss' => __( 'French (Switzerland)', 'multilingual-wp' ), - 'deu' => __( 'German (default)', 'multilingual-wp' ), - 'dea' => __( 'German (Austria)', 'multilingual-wp' ), - 'des' => __( 'German (Switzerland)', 'multilingual-wp' ), - 'ell' => __( 'Greek', 'multilingual-wp' ), - 'hun' => __( 'Hungarian', 'multilingual-wp' ), - 'icelandic' => __( 'Icelandic', 'multilingual-wp' ), - 'ita' => __( 'Italian (default)', 'multilingual-wp' ), - 'italian-swiss' => __( 'Italian (Switzerland)', 'multilingual-wp' ), - 'japanese' => __( 'Japanese', 'multilingual-wp' ), - 'kor' => __( 'Korean', 'multilingual-wp' ), - 'norwegian' => __( 'Norwegian (default)', 'multilingual-wp' ), - 'nor' => __( 'Norwegian (Bokmal)', 'multilingual-wp' ), - 'non' => __( 'Norwegian (Nynorsk)', 'multilingual-wp' ), - 'plk' => __( 'Polish', 'multilingual-wp' ), - 'portuguese' => __( 'Portuguese (default)', 'multilingual-wp' ), - 'portuguese-brazilian' => __( 'Portuguese (Brazil)', 'multilingual-wp' ), - 'rus' => __( 'Russian (default)', 'multilingual-wp' ), - 'sky' => __( 'Slovak', 'multilingual-wp' ), - 'esp' => __( 'Spanish (default)', 'multilingual-wp' ), - 'esm' => __( 'Spanish (Mexico)', 'multilingual-wp' ), - 'esn' => __( 'Spanish (Modern)', 'multilingual-wp' ), - 'sve' => __( 'Swedish', 'multilingual-wp' ), - 'trk' => __( 'Turkish', 'multilingual-wp' ), -); \ No newline at end of file