İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

Bu değişkeni nasıl aktif edebilirim?

emlcvdv

0
İyinet Üyesi
Katılım
18 Kasım 2012
Mesajlar
56
Reaction score
0
Merhaba arkadaşlar. PHP bilmediğimden şu sorunu halledemedim. Sizlerden yardım bekliyorum. wp-includes/media.php dosyasında 2 tane fonksiyondan birinde işe yarayan bir değişken diğerinde işe yaramıyor. Değişken şu: esc_attr($alt)

Fonksiyonlar ise şunlar;

1. Fonksiyon

PHP:
function get_image_tag($id, $alt, $title, $align, $size='medium') {

	list( $img_src, $width, $height ) = image_downsize($id, $size);
	$hwstring = image_hwstring($width, $height);

	$title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';

	$class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id;

	/**
	 * Filter the value of the attachment's image tag class attribute.
	 *
	 * [MENTION=46153]Sinc[/MENTION]e 2.6.0
	 *
	 * @param string $class CSS class name or space-separated list of classes.
	 * @param int    $id    Attachment ID.
	 * @param string $align Part of the class name for aligning the image.
	 * @param string $size  Optional. Default is 'medium'.
	 */
	$class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );

	$html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" ' . $title . $hwstring . 'class="' . $class . '" />';

	/**
	 * Filter the HTML content for the image tag.
	 *
	 * [MENTION=46153]Sinc[/MENTION]e 2.6.0
	 *
	 * @param string $html  HTML content for the image.
	 * @param int    $id    Attachment ID.
	 * @param string $alt   Alternate text.
	 * @param string $title Attachment title.
	 * @param string $align Part of the class name for aligning the image.
	 * @param string $size  Optional. Default is 'medium'.
	 */
	$html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size );

	return $html;
}

2. Fonksiyon:

PHP:
function img_caption_shortcode( $attr, $content = lisanssız ) {
	// New-style shortcode with the caption inside the shortcode with the link and image tags.
	if ( ! isset( $attr['caption'] ) ) {
		if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
			$content = $matches[1];
			$attr['caption'] = trim( $matches[2] );
		}
	}

	/**
	 * Filter the default caption shortcode output.
	 *
	 * If the filtered output isn't empty, it will be used instead of generating
	 * the default caption template.
	 *
	 * [MENTION=46153]Sinc[/MENTION]e 2.6.0
	 *
	 * @see img_caption_shortcode()
	 *
	 * @param string $output  The caption output. Default empty.
	 * @param array  $attr    Attributes of the caption shortcode.
	 * @param string $content The image element, possibly wrapped in a hyperlink.
	 */
	$output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
	if ( $output != '' )
		return $output;

	$atts = shortcode_atts( array(
		'id'	  => '',
		'align'	  => 'alignnone',
		'width'	  => '',
		'caption' => '',
		'class'   => '',
		'alt'   => '',
	), $attr, 'caption' );

	$atts['width'] = (int) $atts['width'];
	if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
		return $content;

	if ( ! empty( $atts['id'] ) )
		$atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';

	$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );

	if ( current_theme_supports( 'html5', 'caption' ) ) {
		return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">'
		. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
	}

	$caption_width = 10 + $atts['width'];

	/**
	 * Filter the width of an image's caption.
	 *
	 * By default, the caption is 10 pixels greater than the width of the image,
	 * to prevent post content from running up against a floated image.
	 *
	 * [MENTION=46153]Sinc[/MENTION]e 3.7.0
	 *
	 * @see img_caption_shortcode()
	 *
	 * @param int    $caption_width Width of the caption in pixels. To remove this inline style,
	 *                              return zero.
	 * @param array  $atts          Attributes of the caption shortcode.
	 * @param string $content       The image element, possibly wrapped in a hyperlink.
	 */
	 
	$caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content );

	$style = '';
	if ( $caption_width )
		$style = 'style="width: ' . (int) $caption_width . 'px" '; 

	return '<h3>' . $atts['caption'] . '</h3><div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
	. do_shortcode( $content ) . '<p class="wp-caption-text">' . esc_attr($alt) . '</p></div>';
}

Benim sorum şu: 1. Fonksiyondaki esc_attr($alt) değişkeni resimlerin alternatif yazılarını çekebiliyorken 2. Fonksiyondaki esc_attr($alt) değişkeni bunu yapamıyor. esc_attr($alt) değişkenini 2. Fonksiyonda da etkin hale nasıl getirebilirim?
 

KrmYlmz

0
İyinet Üyesi
Katılım
3 Kasım 2014
Mesajlar
274
Reaction score
0
PHP:
$atts['id']


değeriniz array içersinde boş tanımlanmış


id yi function () içersinde değişken olarak tanımlamalısınız.
 

emlcvdv

0
İyinet Üyesi
Katılım
18 Kasım 2012
Mesajlar
56
Reaction score
0
PHP:
$atts['id']


değeriniz array içersinde boş tanımlanmış


id yi function () içersinde değişken olarak tanımlamalısınız.

PHP'den pek anlamadığımdan bu dediğinizi yapamam hocam. Kodun düzeltilmiş halini yazmanız mümkün mü? Belki başka faydalananlar da çıkar.
 

KrmYlmz

0
İyinet Üyesi
Katılım
3 Kasım 2014
Mesajlar
274
Reaction score
0
bu işlemi sadece fonksiyonlarla halledemezsiniz. fonksiyonları kullandığınız yerde, fonksiyon içersine id değerini göndermelisiniz.

yani fonksiyonu kullandığınız sayfa önemli burada
 

emlcvdv

0
İyinet Üyesi
Katılım
18 Kasım 2012
Mesajlar
56
Reaction score
0
bu işlemi sadece fonksiyonlarla halledemezsiniz. fonksiyonları kullandığınız yerde, fonksiyon içersine id değerini göndermelisiniz.

yani fonksiyonu kullandığınız sayfa önemli burada

Hocam 1. fonksiyonda dediğiniz şey yapılmış ki, esc_attr($alt) metodu resmin alt metnini çekebiliyor. Aynı şeyin 2. fonksiyon için de yapılması gerekiyor ki esc_attr($alt) metodu yine görevini yapsın. Benim anladığım bu. Birinci fonksiyonu ikinci fonksiyondan ayıran şey ne ki esc_attr($alt) metodu birinde çalışıp diğerinde çalışmıyor, öğrenmek istediğim bu aslında. PHP bilmediğimden dolayı da kodun düzeltilmiş hali lazım bana. yani şunu şunu yap derseniz ben anlayamam ve yapamam açıkçası. Yardım bekliyorum o yüzden sizlerden.
 

KrmYlmz

0
İyinet Üyesi
Katılım
3 Kasım 2014
Mesajlar
274
Reaction score
0
PHP:
function get_image_tag($id, $alt, $title, $align, $size='medium') {
1. fonksiyonunuzun kullanıldığı yerde $alt isminde değişken gönderiliyor.


PHP:
function img_caption_shortcode( $attr, $content = lisanssız ) {
2. fonksiyonunuzda ise böyle bir değişkeniniz mevcut değil.


PHP:
 esc_attr( $atts['id'] )
$atts array inde ki id değerini belirtmişsiniz.

PHP:
     $atts = shortcode_atts( array( 
        'id'      => '', 
        'align'      => 'alignnone', 
        'width'      => '', 
        'caption' => '', 
        'class'   => '', 
        'alt'   => '', 
    ), $attr, 'caption' );

burada id paramatresi boş, yani $alt değişkeni nereden geliyor, neyin içeriği ve 2. fonksiyonu kullandığınız sayfada tanımlımı, eğer tanımlı ise 2. fonksiyona gönderme yapmalısınız.
 

emlcvdv

0
İyinet Üyesi
Katılım
18 Kasım 2012
Mesajlar
56
Reaction score
0
PHP:
function get_image_tag($id, $alt, $title, $align, $size='medium') {
1. fonksiyonunuzun kullanıldığı yerde $alt isminde değişken gönderiliyor.


PHP:
function img_caption_shortcode( $attr, $content = lisanssız ) {
2. fonksiyonunuzda ise böyle bir değişkeniniz mevcut değil.


PHP:
 esc_attr( $atts['id'] )
$atts array inde ki id değerini belirtmişsiniz.

PHP:
     $atts = shortcode_atts( array( 
        'id'      => '', 
        'align'      => 'alignnone', 
        'width'      => '', 
        'caption' => '', 
        'class'   => '', 
        'alt'   => '', 
    ), $attr, 'caption' );

burada id paramatresi boş, yani $alt değişkeni nereden geliyor, neyin içeriği ve 2. fonksiyonu kullandığınız sayfada tanımlımı, eğer tanımlı ise 2. fonksiyona gönderme yapmalısınız.

Yani hocam

PHP:
function img_caption_shortcode( $attr, $content = lisanssız ) {

kodunu

PHP:
function img_caption_shortcode( $attr, $alt, $content = lisanssız ) {

şeklinde düzenlesem olur mu diyorsunuz? Kusura bakmayın dediklerinizi tam anlamıyorum PHP bilgim kıt olduğu için. Eğer demek istediğiniz gibi kodları düzenleyip bana iletirseniz çok makbule geçer. Kaç gündür bununla uğraşıyorum.
 

KrmYlmz

0
İyinet Üyesi
Katılım
3 Kasım 2014
Mesajlar
274
Reaction score
0
orada $alt değişkeni atanacak ancak onemli olan fonksiyonun çalıştırılma yeri

mesela

PHP:
function abc($veri){
...
}

şeklinde bir fonksiyonun kullanımı

PHP:
abc("veri");
şeklinde dir,

bu fonksiyonu siz abc(); şeklinde çalıştırırsanız veriniz işlenmez. yani fonksiyonda yaptığınız bir değişikliği fonksiyonun çalışma alanında da işlemelisiniz ki değişiklik çalışabilsin.
 

emlcvdv

0
İyinet Üyesi
Katılım
18 Kasım 2012
Mesajlar
56
Reaction score
0
orada $alt değişkeni atanacak ancak onemli olan fonksiyonun çalıştırılma yeri

mesela

PHP:
function abc($veri){
...
}

şeklinde bir fonksiyonun kullanımı

PHP:
abc("veri");
şeklinde dir,

bu fonksiyonu siz abc(); şeklinde çalıştırırsanız veriniz işlenmez. yani fonksiyonda yaptığınız bir değişikliği fonksiyonun çalışma alanında da işlemelisiniz ki değişiklik çalışabilsin.

Hocam peki siz 2.fonksiyondaki esc_attr($alt) metodunu çalışır hale getirebilir misiniz, yada 2. fonksiyondaki esc_attr($alt) metodu yerine oraya resim alt metnini çağıracak başka bir kod yazabilir misiniz? Ücret isterseniz de anlarım. Ben gerçekten çok zorlandım bu konuda. Artık bir çare bulmak istiyorum açıkçası.
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Backlink ve Tanıtım Yazısı için iletişime geçmek için Skype Adresimiz: .cid.1580508955483fe5

Üst