כולנו מכירים את הווידג'טים של טקסט, אני לפחות יכולה להעיד שהם הווידג'טים שהכי הרבה בשימוש אצלי.
וכשהמצב נראה כך:

הגבול של 9 ווידג'טים מרגיש מעט קרוב מידי.
אז איך משנים את המצב ?
מעט עריכת קוד והכל נעשה הרבה יותר נעים
הקוד של הווידג'טים יושב בקובץ wp-include/widgets.php
הפונקציה הראשונה לשינוי היא wp_widget_text_setup הנמצאת בשורה 566 של הקובץ.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function wp_widget_text_setup() { $options = $newoptions = get_option('widget_text'); if ( isset($_POST['text-number-submit']) ) { $number = (int) $_POST['text-number']; if ( $number > 9 ) $number = 9; if ( $number < 1 ) $number = 1; $newoptions['number'] = $number; } if ( $options != $newoptions ) { $options = $newoptions; update_option('widget_text', $options); wp_widget_text_register($options['number']); } } |
נשנה את המספר 9 למספר הרצוי (נניח 20).
ונקבל את הקוד הבא:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function wp_widget_text_setup() { $options = $newoptions = get_option('widget_text'); if ( isset($_POST['text-number-submit']) ) { $number = (int) $_POST['text-number']; if ( $number > 20 ) $number =20; if ( $number < 1 ) $number = 1; $newoptions['number'] = $number; } if ( $options != $newoptions ) { $options = $newoptions; update_option('widget_text', $options); wp_widget_text_register($options['number']); } } |
הפונקציה הבאה לטיפול היא wp_widget_text_page הנמצאת בשורה 581.
נשנה את המספר 10 ל-21.
1 2 3 4 5 6 7 8 9 | function wp_widget_text_page() { $options = $newoptions = get_option('widget_text'); ?> <div class="wrap"> <form method="POST"> <h2><?php _e('Text Widgets'); ?></h2> <p style="line-height: 30px;"><?php _e('How many text widgets would you like?'); ?> <select id="text-number" name="text-number" value="<?php echo $options['number']; ?>"> <?php for ( $i = 1; $i < 10; ++$i ) |
לאחר השינוי קיבלנו:
1 2 3 4 5 6 7 8 9 | function wp_widget_text_page() { $options = $newoptions = get_option('widget_text'); ?> <div class="wrap"> <form method="POST"> <h2><?php _e('Text Widgets'); ?></h2> <p style="line-height: 30px;"><?php _e('How many text widgets would you like?'); ?> <select id="text-number" name="text-number" value="<?php echo $options['number']; ?>"> <?php for ( $i = 1; $i < 21; ++$i ) |
נעבור לפונקציה האחרונה wp_widget_text_register הנמצאת בשורה 597.
גם כאן נשנה שוב את המספר 9 ל-20.
1 2 3 4 5 6 7 8 |
ולאחר השינוי
1 2 3 4 5 6 7 8 |
פשוט פשוט פשוט.
מה שכן – תשמרו גיבוי של הקובץ לפני תחילת העריכה, רק ליתר בטחון.
והעיקר – לא לפחד כלל.
נהניתם ? הרשמו לעדכוני RSS !