• 09-12-2021, 04:35:14
    #1
    Aşağıdaki kodlar için PhpStorm şu iki uyarıyı veriyor;

    1. satırı göstererek: Duplicated code fragment (20 lines long)
    2. satırı göstererek: 'if' statement with common parts

    Tam olarak ne demek sitediğini anlamadım?

    echo '<article id="post-0" class="post no-results not-found">';
        if ( current_user_can( 'edit_posts' ) ) {
            // Show a different message to a logged-in user who can add posts.
            echo '<header class="entry-header">
                <h1 class="title">'; _e( 'No posts to display', 'laura' ); echo '</h1>
            </header>
            <div class="entry-content">
                <p>'; printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'laura' ), admin_url( 'post-new.php' ) ); echo '</p>
            </div>';
        } else {
            // Show the default message to everyone else.
            echo '<header class="entry-header">
                <h1 class="title">'; _e( 'Nothing Found', 'laura' ); echo '</h1>
            </header>
            <div class="entry-content">
                <p>'; _e( 'Kindly search your topic below or browse the recent posts.', 'laura' ); echo '</p>';
                get_search_form();
            echo '</div>';
         } // end current_user_can() check
    echo '</article>';
    } // end have_posts() check
  • 09-12-2021, 05:47:42
    #2
    Üyeliği durduruldu
    2. hata ek gereksiz syntax eklendiği için çıkıyor, 1. hata kod tekrarı yüzünden çıkıyor; dert edilebilecek bir şey değil, ayarlardan kapanabiliyor.
  • 09-12-2021, 06:37:53
    #3
    KendineCoder adlı üyeden alıntı: mesajı görüntüle
    2. hata ek gereksiz syntax eklendiği için çıkıyor, 1. hata kod tekrarı yüzünden çıkıyor; dert edilebilecek bir şey değil, ayarlardan kapanabiliyor.
    Kod tekrarını göremedim, ne tür tekrar acaba hocam? Tekrar yazmamayı tercih ederim. Gereksiz olan syntax nedir, onu da gizlemek yerine kaldırayım ki daha temiz bir kodlama ortaya çıksın.
  • 10-12-2021, 13:40:49
    #4
    İF ve ELSE içindeki kodların aynı bunu bir fonksiyon yap sadece değişken alanlarını dışardan çağır kod tekrarı yapma diyor kısacası. Sen 2 yerde aynı kodu cagırıyorsun sadece içeriğinde sonuc kısmı farklı