Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
seebeen committed Nov 13, 2020
2 parents 7d7dcd3 + f5f6b70 commit ca0791d
Show file tree
Hide file tree
Showing 34 changed files with 541 additions and 513 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"require": {
"simplehtmldom/simplehtmldom": "2.0-RC2",
"sgi/transliterator": "^1.0",
"sgi/asset-loader": "^1.1"
"sgi/transliterator": "^1.0"
}
}
53 changes: 31 additions & 22 deletions lib/Admin/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use const SGI\STL\{
BASENAME,
VERSION,
DOMAIN,
PATH
};

Expand Down Expand Up @@ -34,7 +32,8 @@ public function __construct()


//Filename transliteration
//add_filter('sanitize_file_name', array(&$this, 'sanitize_file_name'),50,2);
add_filter('sanitize_file_name', array(&$this, 'sanitizeFilename'),50,2);
add_filter('sanitize_title', [&$this, 'sanitizeTitle'], 100, 2);

}

Expand All @@ -44,7 +43,7 @@ public function pluginLinks($links)
$links[] = sprintf(
'<a href="%s">%s</a>',
admin_url('admin.php?page=stl_settings'),
__('Settings', DOMAIN)
__('Settings', 'SrbTransLatin')
);

return $links;
Expand All @@ -61,39 +60,27 @@ public function pluginMeta($plugin_meta, $plugin_file)
$plugin_meta[] = sprintf(
'<a href="%s" target="_blank">%s</a>',
'https://sgi.io/plugins/srbtranslatin',
__('Documentation', DOMAIN)
__('Documentation', 'SrbTransLatin')
);

$plugin_meta[] = sprintf(
'<a href="%s" target="_blank"><strong>%s</strong></a>',
'https://paypal.me/seebeen',
__('Donate', DOMAIN)
__('Donate', 'SrbTransLatin')
);

return $plugin_meta;

}

public function sanitize_file_name($filename, $filename_raw)
{

if (!$this->opts['file']['names'])
return $filename;

$filename = Transliterator::cir_to_cut_lat($filename);

return $filename;

}

public function addMenuPages()
{

$image = file_get_contents(PATH . 'assets/img/stl-logo.svg');

add_menu_page(
__('Latinisation', DOMAIN),
__('Latinisation', DOMAIN),
__('Latinisation', 'SrbTransLatin'),
__('Latinisation', 'SrbTransLatin'),
'manage_options',
'stl',
function(){},
Expand All @@ -103,8 +90,8 @@ function(){},

add_submenu_page(
'stl',
__('Settings - SrbTransLatin', DOMAIN),
__('Settings', DOMAIN),
__('Settings - SrbTransLatin', 'SrbTransLatin'),
__('Settings', 'SrbTransLatin'),
'manage_options',
'stl_settings',
[&$this, 'settings_page']
Expand All @@ -131,5 +118,27 @@ public function settings_page()
echo '</form>';
}

public function sanitizeFilename($filename, $filename_raw)
{

if (!$this->opts['file']['names'])
return $filename;

$filename = Transliterator::cir_to_cut_lat($filename);

return $filename;

}

public function sanitizeTitle($title, $fallback_title)
{

if (!$this->opts['fixes']['permalinks'])
return $title;

return Transliterator::cir_to_cut_lat(($title));

}


}
82 changes: 0 additions & 82 deletions lib/Admin/Scripts.php

This file was deleted.

30 changes: 15 additions & 15 deletions lib/Admin/Settings/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public function section_files()

add_settings_section(
'stl_settings_file',
__('File and Media Settings', DOMAIN),
__('File and Media Settings', 'SrbTransLatin'),
[&$this, 'callback_section_files'],
'stl_settings'
);

add_settings_field(
'stl_file_names',
__('Fix Filenames', DOMAIN),
__('Fix Filenames', 'SrbTransLatin'),
[&$this, 'callback_option_names'],
'stl_settings',
'stl_settings_file',
Expand All @@ -28,7 +28,7 @@ public function section_files()

add_settings_field(
'stl_file_translit',
__('Latin speficic filenames', DOMAIN),
__('Latin speficic filenames', 'SrbTransLatin'),
[&$this, 'callback_option_translit'],
'stl_settings',
'stl_settings_file',
Expand All @@ -40,7 +40,7 @@ public function section_files()

add_settings_field(
'stl_file_delim',
__('Filename delimiter', DOMAIN),
__('Filename delimiter', 'SrbTransLatin'),
[&$this, 'callback_option_delim'],
'stl_settings',
'stl_settings_file',
Expand All @@ -49,7 +49,7 @@ public function section_files()

// add_settings_field(
// 'stl_core_content',
// __('Cookie', DOMAIN),
// __('Cookie', 'SrbTransLatin'),
// [&$this, 'callback_option_content'],
// 'stl_settings',
// 'stl_settings_file',
Expand All @@ -63,7 +63,7 @@ public function callback_section_files()

printf(
'<p>%s</p>',
__('File & Media settings control filename transliteration and media saving', DOMAIN)
__('File & Media settings control filename transliteration and media saving', 'SrbTransLatin')
);

}
Expand All @@ -74,9 +74,9 @@ public function callback_option_names($names)
self::checkbox(
$names,
'sgi/stl/opt[file][names]',
$this->expert_enable,
__('Transliterate filenames', DOMAIN),
__('Enable if you want to convert cyrillic filenames to latin', DOMAIN)
true,
__('Transliterate filenames', 'SrbTransLatin'),
__('Enable if you want to convert cyrillic filenames to latin', 'SrbTransLatin')
);

}
Expand All @@ -88,8 +88,8 @@ public function callback_option_translit($opts)
$opts['translit'],
'sgi/stl/opt[file][translit]',
true,
__('Script specific filenames', DOMAIN),
__('Enable if you want to have cyrillic and latin versions of an image ', DOMAIN)
__('Script specific filenames', 'SrbTransLatin'),
__('Enable if you want to have cyrillic and latin versions of an image ', 'SrbTransLatin')
);

echo '<div class="stl-content-only" style="margin-top:20px;">';
Expand All @@ -98,8 +98,8 @@ public function callback_option_translit($opts)
$opts['names'],
'sgi/stl/opt[file][content]',
true,
__('Script specific filenames in content only', DOMAIN),
__('Enable if you want to limit different filenames to post/page content only', DOMAIN)
__('Script specific filenames in content only', 'SrbTransLatin'),
__('Enable if you want to limit different filenames to post/page content only', 'SrbTransLatin')
);

echo '</div>';
Expand All @@ -112,9 +112,9 @@ public function callback_option_delim($delim)
self::input(
$delim,
'sgi/stl/opt[file][delim]',
$this->expert_enable,
false,
'',
__('Filename delimiter - i.e. - myfilename-cir.jpg', DOMAIN)
__('Filename delimiter - i.e. - myfilename-cir.jpg', 'SrbTransLatin')
);

}
Expand Down
Loading

0 comments on commit ca0791d

Please sign in to comment.