if ( isset( $options['chk_plus'] ) && $options['chk_plus'] ) {
$char_array[] = '+';
burda ki + krakterini rakam olarak nasıl değiştirebilirim bu kısım yazıda + işaretlerini görünce siliyor onun yerine rakamları silmesini istiyorum nasıl değiştirebilirim asıl dosyada aşağıda
/*
Plugin Name: Format Media Titles
Plugin URI: http://www.wpgothemes.com/plugins/format-media-titles/
Description: Automatically formats the title for new media uploads. No need to manually edit the title anymore every time you upload an image!
Version: 0.50
Author: David Gwyer
Author URI: http://www.wpgoplugins.com
*/
/* Copyright 2009 David Gwyer (email : david@wpgoplugins.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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Plugin Prefix: 'fmt_' prefix is derived from [f]ormat [m]edia [t]itles. */
/* Set-up Hooks. */
register_activation_hook( __FILE__, 'fmt_add_defaults' );
register_uninstall_hook( __FILE__, 'fmt_delete_plugin_options' );
add_action( 'admin_menu', 'fmt_add_options_page' );
add_action('admin_init', 'fmt_init' );
add_action( 'add_attachment', 'fmt_update_media_title' );
add_filter( 'plugin_row_meta', 'fmt_plugin_action_links', 10, 2 );
add_filter( 'plugin_action_links', 'fmt_plugin_settings_link', 10, 2 );
add_action( 'plugins_loaded', 'fmt_localize_plugin' );
add_action( 'admin_notices', 'fmt_admin_notice' );
register_activation_hook( __FILE__, 'fmt_admin_notice_set_transient' );
/* Runs only when the plugin is activated. */
function fmt_admin_notice_set_transient() {
/* Create transient data */
set_transient( 'fmt-admin-notice', true, 5 );
}
/* Admin Notice on Activation. */
function fmt_admin_notice(){
/* Check transient, if available display notice */
if( get_transient( 'fmt-admin-notice' ) ){
?>
Format Media Titles PRO is now available! Access great new features such as the batch processor to actively reformat all existing media. Try risk free today with our 100% money back guarantee!
/* Delete transient, only display this notice once. */
delete_transient( 'fmt-admin-notice' );
}
}
function fmt_localize_plugin() {
load_plugin_textdomain( 'format-media-titles', false, basename( dirname( __FILE__ ) ) . '/languages/' );
}
/* Delete options table entries ONLY when plugin deactivated AND deleted. */
function fmt_delete_plugin_options() {
delete_option( 'fmt_options' );
}
/* Define default option settings. */
function fmt_add_defaults() {
$tmp = get_option( 'fmt_options' );
if ( ( isset($tmp['chk_default_options_db']) && $tmp['chk_default_options_db'] == '1' ) || ( ! is_array( $tmp ) ) ) {
delete_option( 'fmt_options' );
$arr = array( "chk_hyphen" => "1",
"chk_underscore" => "1",
"rdo_cap_options" => "cap_all"
);
update_option( 'fmt_options', $arr );
}
}
/* Init plugin options to white list our options. */
function fmt_init(){
register_setting( 'fmt_plugin_options', 'fmt_options' );
}
/* Add menu page. */
function fmt_add_options_page() {
add_options_page( 'Format Media Titles Options Page', 'Format Media Titles', 'manage_options', __FILE__, 'fmt_render_form' );
}
/* Render Plugin options form. */
function fmt_render_form() {
?>
}
/* Display a Settings link on the main Plugins page. */
function fmt_plugin_action_links( $links, $file ) {
//if ( $file == plugin_basename( __FILE__ ) ) {
// add a link to pro plugin
//$links[] = '';
//}
return $links;
}
/* Display a Settings link on the main Plugins page. */
function fmt_plugin_settings_link( $links, $file ) {
if ( $file == plugin_basename( __FILE__ ) ) {
$pccf_links = '' . __( 'Settings' ) . '';
array_unshift( $links, $pccf_links );
}
if ( $file == plugin_basename( __FILE__ ) ) {
$pccf_links = '';
array_push( $links, $pccf_links );
}
return $links;
}
function fmt_update_media_title( $id ) {
$options = get_option( 'fmt_options' );
$cap_options = $options['rdo_cap_options'];
$uploaded_post_id = get_post( $id );
$title = $uploaded_post_id->post_title;
/* Update post. */
$char_array = array();
if ( isset( $options['chk_hyphen'] ) && $options['chk_hyphen'] ) {
$char_array[] = '-';
}
if ( isset( $options['chk_underscore'] ) && $options['chk_underscore'] ) {
$char_array[] = '_';
}
if ( isset( $options['chk_period'] ) && $options['chk_period'] ) {
$char_array[] = '.';
}
if ( isset( $options['chk_tilde'] ) && $options['chk_tilde'] ) {
$char_array[] = '~';
}
if ( isset( $options['chk_plus'] ) && $options['chk_plus'] ) {
$char_array[] = '+';
}
/* Replace chars with spaces, if any selected. */
if ( ! empty( $char_array ) ) {
$title = str_replace( $char_array, ' ', $title );
}
/* Trim multiple spaces between words. */
$title = preg_replace( "/\s+/", " ", $title );
/* Capitalize Title. */
switch ( $cap_options ) {
case 'cap_all':
$title = ucwords( $title );
break;
case 'cap_first':
$title = ucfirst( strtolower( $title ) );
break;
case 'all_lower':
$title = strtolower( $title );
break;
case 'all_upper':
$title = strtoupper( $title );
break;
case 'dont_alter':
/* Leave title as it is. */
break;
}
// add formatted title to the alt meta field
if ( isset( $options['chk_alt'] ) && $options['chk_alt'] ) {
update_post_meta( $id, '_wp_attachment_image_alt', $title );
}
// update the post
$uploaded_post = array();
$uploaded_post['ID'] = $id;
$uploaded_post['post_title'] = $title;
// add formatted title to the description meta field
if ( isset( $options['chk_description'] ) && $options['chk_description'] ) {
$uploaded_post['post_content'] = $title;
}
// add formatted title to the caption meta field
if ( isset( $options['chk_caption'] ) && $options['chk_caption'] ) {
$uploaded_post['post_excerpt'] = $title;
}
wp_update_post( $uploaded_post );
}